diff --git a/app.js b/app.js index 852124a..bb7d4c4 100644 --- a/app.js +++ b/app.js @@ -56,6 +56,7 @@ const PROVINCE_BY_PLATE_PREFIX = { let map = null; let markerList = []; +let infoWindowList = []; let is3DPitch = true; let currentMode = 'vehicle'; let currentTheme = 'theme-white'; @@ -239,6 +240,7 @@ function stationNodes() { function renderAMapMarkers() { if (!map || !dashboard) return; markerList.forEach(marker => marker.remove()); markerList = []; + infoWindowList.forEach(infoWindow => infoWindow.close()); infoWindowList = []; const nodes = currentMode === 'vehicle' ? vehicleNodes() : stationNodes(); const dict = i18n[currentLang]; for (const node of nodes) { @@ -253,6 +255,7 @@ function renderAMapMarkers() { content: `
${escapeHTML(node.name)}
${escapeHTML(node.detail || '')}
${isVehicleNode ? `
${dict.onlineText}: ${node.online}/${node.count} ยท ${formatNumber(node.dist, 1)} km
` : ''}
`, offset: new AMap.Pixel(0, -32) }); + infoWindowList.push(infoWindow); marker.on('mouseover', () => infoWindow.open(map, node.lnglat)); marker.on('mouseout', () => infoWindow.close()); if (node.kind === 'vehicleProvince') marker.on('click', () => map.setZoomAndCenter(7.2, node.lnglat));