|
|
@ -405,6 +405,8 @@ const selectedDockIds = reactive(new Set()) |
|
|
|
|
|
|
|
|
let mapInstance = null |
|
|
let mapInstance = null |
|
|
let layersReady = false |
|
|
let layersReady = false |
|
|
|
|
|
let pendingLoadHandler = null |
|
|
|
|
|
let pendingStyleHandler = null |
|
|
const mapMode = ref('satellite') |
|
|
const mapMode = ref('satellite') |
|
|
const mapScaleText = ref('2 km') |
|
|
const mapScaleText = ref('2 km') |
|
|
let suppressMapClick = false |
|
|
let suppressMapClick = false |
|
|
@ -460,7 +462,7 @@ function devicesFeatureCollection() { |
|
|
assetId: String(asset.id), |
|
|
assetId: String(asset.id), |
|
|
name: asset.name || '', |
|
|
name: asset.name || '', |
|
|
kind: asset.type, |
|
|
kind: asset.type, |
|
|
selected, |
|
|
|
|
|
|
|
|
selected: selected ? 1 : 0, |
|
|
color: statusColor(asset.statusClass), |
|
|
color: statusColor(asset.statusClass), |
|
|
radius: asset.type === 'drone' ? (selected ? 10 : 8) : (selected ? 12 : 10), |
|
|
radius: asset.type === 'drone' ? (selected ? 10 : 8) : (selected ? 12 : 10), |
|
|
}, |
|
|
}, |
|
|
@ -520,7 +522,7 @@ function ensureMonitorLayers() { |
|
|
'circle-stroke-color': '#fff', |
|
|
'circle-stroke-color': '#fff', |
|
|
'circle-stroke-width': [ |
|
|
'circle-stroke-width': [ |
|
|
'case', |
|
|
'case', |
|
|
['to-boolean', ['get', 'selected']], |
|
|
|
|
|
|
|
|
['==', ['get', 'selected'], 1], |
|
|
3, |
|
|
3, |
|
|
2, |
|
|
2, |
|
|
], |
|
|
], |
|
|
@ -605,7 +607,25 @@ function syncBindingLine() { |
|
|
if (src) src.setData(bindingFeatureCollection()) |
|
|
if (src) src.setData(bindingFeatureCollection()) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function cancelPendingMapHandlers() { |
|
|
|
|
|
if (!mapInstance) { |
|
|
|
|
|
pendingLoadHandler = null |
|
|
|
|
|
pendingStyleHandler = null |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (pendingLoadHandler) { |
|
|
|
|
|
mapInstance.off('load', pendingLoadHandler) |
|
|
|
|
|
pendingLoadHandler = null |
|
|
|
|
|
} |
|
|
|
|
|
if (pendingStyleHandler) { |
|
|
|
|
|
mapInstance.off('style.load', pendingStyleHandler) |
|
|
|
|
|
pendingStyleHandler = null |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function rebuildAfterStyle() { |
|
|
function rebuildAfterStyle() { |
|
|
|
|
|
pendingStyleHandler = null |
|
|
|
|
|
if (!mapInstance) return |
|
|
layersReady = false |
|
|
layersReady = false |
|
|
ensureMonitorLayers() |
|
|
ensureMonitorLayers() |
|
|
syncMarkers() |
|
|
syncMarkers() |
|
|
@ -623,8 +643,13 @@ function setMapMode(mode) { |
|
|
} |
|
|
} |
|
|
mapMode.value = mode |
|
|
mapMode.value = mode |
|
|
layersReady = false |
|
|
layersReady = false |
|
|
|
|
|
if (pendingStyleHandler) { |
|
|
|
|
|
mapInstance.off('style.load', pendingStyleHandler) |
|
|
|
|
|
pendingStyleHandler = null |
|
|
|
|
|
} |
|
|
mapInstance.setStyle(MAP_STYLES[mode] || MAP_STYLES.satellite) |
|
|
mapInstance.setStyle(MAP_STYLES[mode] || MAP_STYLES.satellite) |
|
|
mapInstance.once('style.load', rebuildAfterStyle) |
|
|
|
|
|
|
|
|
pendingStyleHandler = rebuildAfterStyle |
|
|
|
|
|
mapInstance.once('style.load', pendingStyleHandler) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function fitAll() { |
|
|
function fitAll() { |
|
|
@ -698,6 +723,8 @@ async function setupMap() { |
|
|
mapHelper.toggleMapMode({ is2D: true }) |
|
|
mapHelper.toggleMapMode({ is2D: true }) |
|
|
|
|
|
|
|
|
const onReady = () => { |
|
|
const onReady = () => { |
|
|
|
|
|
pendingLoadHandler = null |
|
|
|
|
|
if (!mapInstance) return |
|
|
ensureMonitorLayers() |
|
|
ensureMonitorLayers() |
|
|
syncMarkers() |
|
|
syncMarkers() |
|
|
if (selectedId.value) flyToSelected() |
|
|
if (selectedId.value) flyToSelected() |
|
|
@ -705,8 +732,12 @@ async function setupMap() { |
|
|
updateMapScale() |
|
|
updateMapScale() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
cancelPendingMapHandlers() |
|
|
if (map.isStyleLoaded()) onReady() |
|
|
if (map.isStyleLoaded()) onReady() |
|
|
else map.once('load', onReady) |
|
|
|
|
|
|
|
|
else { |
|
|
|
|
|
pendingLoadHandler = onReady |
|
|
|
|
|
map.once('load', pendingLoadHandler) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
map.on('click', onMapClick) |
|
|
map.on('click', onMapClick) |
|
|
map.on('zoom', updateMapScale) |
|
|
map.on('zoom', updateMapScale) |
|
|
@ -714,6 +745,7 @@ async function setupMap() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function teardownMap() { |
|
|
function teardownMap() { |
|
|
|
|
|
cancelPendingMapHandlers() |
|
|
if (mapInstance) { |
|
|
if (mapInstance) { |
|
|
mapInstance.off('click', onMapClick) |
|
|
mapInstance.off('click', onMapClick) |
|
|
mapInstance.off('zoom', updateMapScale) |
|
|
mapInstance.off('zoom', updateMapScale) |
|
|
@ -721,6 +753,7 @@ function teardownMap() { |
|
|
clearMonitorLayers() |
|
|
clearMonitorLayers() |
|
|
} |
|
|
} |
|
|
mapInstance = null |
|
|
mapInstance = null |
|
|
|
|
|
layersReady = false |
|
|
commonRefs.clearPendingList('map') |
|
|
commonRefs.clearPendingList('map') |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|