| | |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | |
| | | if (!this.map) { |
| | | this.currentMakers = JSON.parse(JSON.stringify(newData)) |
| | | this.markers = newData |
| | |
| | | newData.forEach(newMarker => { |
| | | const markerId = `${newMarker.longitude}-${newMarker.latitude}` |
| | | const existingMarker = this.markerObjects[markerId] |
| | | |
| | | |
| | | if (existingMarker) { |
| | | // Update existing marker content |
| | | const content = this.generateMarkerContent(newMarker) |
| | |
| | | // Remove markers that no longer exist |
| | | Object.keys(this.markerObjects).forEach(markerId => { |
| | | const [longitude, latitude] = markerId.split('-') |
| | | const markerExists = newData.some(marker => |
| | | marker.longitude === parseFloat(longitude) && |
| | | const markerExists = newData.some(marker => |
| | | marker.longitude === parseFloat(longitude) && |
| | | marker.latitude === parseFloat(latitude) |
| | | ) |
| | | |
| | | |
| | | if (!markerExists) { |
| | | this.markerObjects[markerId].setMap(null) |
| | | delete this.markerObjects[markerId] |
| | |
| | | }, |
| | | async initMap() { |
| | | const map = await AMapLoader.load({ |
| | | key: '67968c82f27c7e2cb9f40c1a9aa3042b', |
| | | key: '526e04b30ceba8f217c5def5a92392f9', |
| | | version: '2.0', |
| | | plugins: ['AMap.MarkerClusterer'] |
| | | }) |