Browse Source

加载地图移至App

HuangKai 1 week ago
parent
commit
8671a978ae
1 changed files with 17 additions and 0 deletions
  1. 17 0
      src/view/App.js

+ 17 - 0
src/view/App.js

@@ -310,4 +310,21 @@ export default class App {
 		PubSub.publish('body.data.update', cards);
 		PubSub.publish('body.data.update', cards);
 	  }
 	  }
 	}
 	}
+
+	/** * 加载地图文件 * * 
+	 * @param {String} url - 地图文件路径 * 
+	*/
+	loadMap(url) {   
+		fetch(url)
+			.then(res => res.text())
+			.then(data => {
+				// 处理获取的数据
+				let json = JSON.parse(data);
+				PubSub.publish("body.draw.loaded", json);
+			})
+			.catch(error => {
+				// 处理错误
+				console.error('There was a problem with the fetch operation:', error);
+			});
+	}
 }
 }