hejianhao
2026-02-04 4c98a2b424462836191b109717a3f33fab09ac89
fix: 修正地图工具提示位置在缩放时的偏移问题

通过获取应用容器的实际缩放比例,对工具提示坐标进行反向补偿,确保在不同缩放级别下位置准确。
1个文件已修改
19 ■■■■■ 已修改文件
screen/src/view/home/index.vue 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
screen/src/view/home/index.vue
@@ -1311,7 +1311,24 @@
      if (!this.mapView) return;
      const pixel = this.mapView.lngLatToContainer(item.position);
      this.tooltipPos = { left: pixel.x, top: pixel.y };
      // 获取当前缩放比例
      let scaleX = 1;
      let scaleY = 1;
      const app = document.querySelector('#app');
      if (app) {
        const rect = app.getBoundingClientRect();
        // offsetWidth 是元素的布局宽度(不包含 transform)
        // rect.width 是元素的渲染宽度(包含 transform)
        if (app.offsetWidth > 0) {
          scaleX = rect.width / app.offsetWidth;
        }
        if (app.offsetHeight > 0) {
          scaleY = rect.height / app.offsetHeight;
        }
      }
      this.tooltipPos = { left: pixel.x / scaleX, top: pixel.y / scaleY - 60 };
      this.tooltipVisible = true;
      this.tooltipLoading = true;
      this.tooltipError = false;