|
|
@@ -85,6 +85,7 @@ export default {
|
|
|
intersectionData: [],
|
|
|
statusIntersections: {},
|
|
|
currentZoomSize: 14, // 保存当前的动态尺寸
|
|
|
+ markerById: {}, // ID → marker 索引,加速 focusById 查找
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
@@ -313,7 +314,7 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- this.map.on('zoomchange', () => {
|
|
|
+ this.map.on('zoomend', () => {
|
|
|
if (!this.isComponentDestroyed) {
|
|
|
this.currentZoomSize = this.getDotSizeByZoom();
|
|
|
}
|
|
|
@@ -1010,6 +1011,10 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ // 建立 ID 索引
|
|
|
+ if (config.id) this.markerById[config.id] = marker;
|
|
|
+ if (config['路口编号']) this.markerById[config['路口编号']] = marker;
|
|
|
+
|
|
|
marker.on('click', (e) => {
|
|
|
if (this.isComponentDestroyed) return;
|
|
|
const extData = e.target.getExtData();
|
|
|
@@ -1288,21 +1293,9 @@ export default {
|
|
|
focusById(id) {
|
|
|
if (!this.isMapReady() || !id) return null;
|
|
|
|
|
|
- let bestMarker = null;
|
|
|
- Object.values(this.routeGroups).forEach(group => {
|
|
|
- if (!Array.isArray(group) || bestMarker) return;
|
|
|
- group.forEach(item => {
|
|
|
- if (bestMarker) return;
|
|
|
- if (!(item instanceof this.AMap.Marker)) return;
|
|
|
- const ext = item.getExtData();
|
|
|
- if (ext.id === id || ext['路口编号'] === id) {
|
|
|
- bestMarker = item;
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- if (bestMarker) {
|
|
|
- const finalPos = bestMarker.getPosition();
|
|
|
+ const marker = this.markerById[id];
|
|
|
+ if (marker) {
|
|
|
+ const finalPos = marker.getPosition();
|
|
|
this.map.setZoomAndCenter(17, finalPos, false, 500);
|
|
|
return finalPos;
|
|
|
}
|