antvis / L7

🌎 Large-scale WebGL-powered Geospatial Data Visualization analysis engine.

Home Page:https://l7.antv.antgroup.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

v2.21.1以上版本,地图设置为无底图模式时,获取经纬度的控件会显示(0,0)

Dreammy23 opened this issue · comments

问题描述

最新版本的经纬度控件在无底图模式下无法正确获取坐标

重现链接

No response

重现步骤

No response

预期行为

我期望看到坐标随鼠标移动正常展示

平台

No response

屏幕截图或视频(可选)

image

补充说明(可选)

No response

L7 研发环境调试正常

image

打包发布后,业务线上使用都会显示 (0,0)

可能是打包编译时,代码出现的问题?

编译前的代码,四年前写的没有动过

export class Event {
public type: string;
constructor(type: string, data: any = {}) {
merge(this, data);
this.type = type;
}
}

export default class MapMouseEvent extends Event {
/**
* `true` if `preventDefault` has been called.
* @private
*/
public type:
| 'mousedown'
| 'mouseup'
| 'click'
| 'dblclick'
| 'mousemove'
| 'mouseover'
| 'mouseenter'
| 'mouseleave'
| 'mouseout'
| 'contextmenu';
/**
* The `Map` object that fired the event.
*/
public target: Map | EarthMap;
/**
* The DOM event which caused the map event.
*/
public originalEvent: MouseEvent;
/**
* The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.
*/
public point: Point;
/**
* The geographic location on the map of the mouse cursor.
*/
public lngLat: LngLat;
public defaultPrevented: boolean;
/**
* @private
*/
constructor(
type: string,
map: Map | EarthMap,
originalEvent: MouseEvent,
data: any = {},
) {
const point = DOM.mousePos(map.getCanvasContainer(), originalEvent);
const lngLat = map.unproject(point);
super(type, merge({ point, lngLat, originalEvent }, data));
this.defaultPrevented = false;
this.target = map;
}

看似无毒无害,简化复现一下

class A {
  public arg1: number
  constructor(arg1: number, arg2: number) {
    this.arg1 = arg1;
    this.arg2 = arg2;
  }
}


class B extends A {
  public arg2: number
  public arg3: number
  constructor(arg1: number, arg2: number, arg3: number) {
    super(arg1, arg2);
    this.arg3 = arg3;
  }
}

const b = new B(1, 2, 3)
console.log(b)

再简化一下转化为 JS 的

class A {
   arg1
  constructor(arg1, arg2) {
    this.arg1 = arg1;
    this.arg2 = arg2;
  }
}


class B extends A {
   arg2
   arg3
  constructor(arg1, arg2, arg3) {
    super(arg1, arg2);
    this.arg3 = arg3;
  }
}

const b = new B(1, 2, 3)
console.log(b)

执行结果是什么?

image

打包时,使用了 Babel 进行了编译,默认配置编译后的结果

babel repl

image

给 babel 如果加了 @babel/plugin-transform-typescript 插件,编译后的结果

babel repl

image

如果使用 typescript 编译

TS Playground

image

忽略编译错误,执行结果

image

@lvisei 所以老哥最后如何改这个问题。加上pnpm add --save-dev @babel/plugin-transform-typescript ???

最后如何改这个问题。加上pnpm add --s

等今天修复了发个版本

等今天修复了发个版本

#2437