|
|
@@ -159,6 +159,9 @@ export default {
|
|
|
// 关闭信息窗口
|
|
|
if (this.infoWindow) this.infoWindow.close();
|
|
|
|
|
|
+ // 确保地图已初始化
|
|
|
+ if (!this.map) return;
|
|
|
+
|
|
|
// 根据activeLegends数组更新地图上路线和标记的显示/隐藏状态
|
|
|
Object.keys(this.routeGroups).forEach(name => {
|
|
|
const overlays = this.routeGroups[name];
|
|
|
@@ -265,7 +268,8 @@ export default {
|
|
|
const overlays = [...markers, polyline].filter(Boolean);
|
|
|
this.routeGroups[config.name] = overlays;
|
|
|
|
|
|
- if (this.activeLegends.includes(config.name)) {
|
|
|
+ // 确保地图已初始化
|
|
|
+ if (this.map && this.activeLegends.includes(config.name)) {
|
|
|
this.map.add(overlays);
|
|
|
}
|
|
|
});
|