1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| for (const [index, item] of new Map(this.treeData.map((item, index) => [index, item]))) { let marker let position if (index === 0) { position = new AMap.LngLat(item.longitude, item.latitude) marker = new AMap.Marker({ icon: lampIconActive, position: position, offset: new AMap.Pixel(-17, -10) }) this.activeMarker = 0 map.add(marker) } else { position = new AMap.LngLat(item.longitude, item.latitude) marker = new AMap.Marker({ icon: lampIcon, position: position, offset: new AMap.Pixel(-17, -10) }) map.add(marker) } this.allMarkers.push(marker) marker.on('click', e => { map.setZoomAndCenter(centerFloor, e.target.getPosition()) this.allMarkers[this.activeMarker].setIcon(lampIcon) for (var i = 0;i < this.allMarkers.length;i++) { if (this.allMarkers[i]._amap_id === e.target._amap_id) { this.activeMarker = i } } e.target.setIcon(lampIconActive) }) }
|