Browse Source

fix: keep monitor map on globe projection

is2D previously forced mercator for route editing and flattened the
monitor overview. Split projection control; monitor sets globe,
route editor sets mercator only while attached.
main
xiaosi 2 weeks ago
parent
commit
e4854065a9
  1. 22
      src/core/mapHelper.js
  2. 1
      src/views/MonitorView/MonitorView.vue
  3. 1
      src/views/TasksView/TasksView.vue

22
src/core/mapHelper.js

@ -19,11 +19,6 @@ class MapHelper {
if (!this._map) return if (!this._map) return
if (is3D) { if (is3D) {
try {
this._map.setProjection('globe')
} catch (_) {
/* ignore */
}
this._map.easeTo({ pitch: 45, bearing: 0, duration: 0 }) this._map.easeTo({ pitch: 45, bearing: 0, duration: 0 })
this._map.dragRotate.enable() this._map.dragRotate.enable()
this._map.touchZoomRotate.enableRotation() this._map.touchZoomRotate.enableRotation()
@ -32,12 +27,8 @@ class MapHelper {
} }
if (is2D) { if (is2D) {
// 航线/回放编辑需要平面投影;globe 下短航线 fitBounds 易失效
try {
this._map.setProjection('mercator')
} catch (_) {
/* ignore */
}
// 只锁俯仰/旋转;投影由 setProjection 单独控制
// 监控要 globe 圆形地球,航线编辑要 mercator
this._map.easeTo({ pitch: 0, bearing: 0, duration: 0 }) this._map.easeTo({ pitch: 0, bearing: 0, duration: 0 })
this._map.dragRotate.disable() this._map.dragRotate.disable()
this._map.touchZoomRotate.disableRotation() this._map.touchZoomRotate.disableRotation()
@ -46,6 +37,15 @@ class MapHelper {
} }
} }
setProjection(name) {
if (!this._map || !name) return
try {
this._map.setProjection(name)
} catch (_) {
/* ignore */
}
}
replaceMapContainer(newParent) { replaceMapContainer(newParent) {
if (!this._map || !newParent) return if (!this._map || !newParent) return

1
src/views/MonitorView/MonitorView.vue

@ -613,6 +613,7 @@ async function setupMap() {
mapInstance = map mapInstance = map
if (typeof window !== 'undefined') window.__LAIC_MAP__ = map if (typeof window !== 'undefined') window.__LAIC_MAP__ = map
mapHelper.toggleMapMode({ is2D: true }) mapHelper.toggleMapMode({ is2D: true })
mapHelper.setProjection('globe')
updateMapScale() updateMapScale()
let readyStarted = false let readyStarted = false

1
src/views/TasksView/TasksView.vue

@ -794,6 +794,7 @@ async function attachRouteMap() {
routeMapInstance = map routeMapInstance = map
mapHelper.replaceMapContainer(host) mapHelper.replaceMapContainer(host)
mapHelper.toggleMapMode({ is2D: true }) mapHelper.toggleMapMode({ is2D: true })
mapHelper.setProjection('mercator')
routeMapAttached = true routeMapAttached = true
routeMapReady.value = false routeMapReady.value = false

Loading…
Cancel
Save