diff --git a/src/core/mapHelper.js b/src/core/mapHelper.js index e881941..94d6a18 100644 --- a/src/core/mapHelper.js +++ b/src/core/mapHelper.js @@ -19,11 +19,6 @@ class MapHelper { if (!this._map) return if (is3D) { - try { - this._map.setProjection('globe') - } catch (_) { - /* ignore */ - } this._map.easeTo({ pitch: 45, bearing: 0, duration: 0 }) this._map.dragRotate.enable() this._map.touchZoomRotate.enableRotation() @@ -32,12 +27,8 @@ class MapHelper { } 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.dragRotate.disable() 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) { if (!this._map || !newParent) return diff --git a/src/views/MonitorView/MonitorView.vue b/src/views/MonitorView/MonitorView.vue index 960e8ae..5a2e5ab 100644 --- a/src/views/MonitorView/MonitorView.vue +++ b/src/views/MonitorView/MonitorView.vue @@ -613,6 +613,7 @@ async function setupMap() { mapInstance = map if (typeof window !== 'undefined') window.__LAIC_MAP__ = map mapHelper.toggleMapMode({ is2D: true }) + mapHelper.setProjection('globe') updateMapScale() let readyStarted = false diff --git a/src/views/TasksView/TasksView.vue b/src/views/TasksView/TasksView.vue index 992dd67..723304f 100644 --- a/src/views/TasksView/TasksView.vue +++ b/src/views/TasksView/TasksView.vue @@ -794,6 +794,7 @@ async function attachRouteMap() { routeMapInstance = map mapHelper.replaceMapContainer(host) mapHelper.toggleMapMode({ is2D: true }) + mapHelper.setProjection('mercator') routeMapAttached = true routeMapReady.value = false