fix: marker 支持样式 & 高德地图可以关闭offset坐标系

This commit is contained in:
thinkinggis 2020-12-21 15:06:29 +08:00
parent 73c15918ed
commit 23f01516e8
3 changed files with 22 additions and 5 deletions

View File

@ -156,6 +156,15 @@ L7 Logo 的显示位置 默认左下角
地图是否可旋转 {Boolean} default true
## 实验参数
参数可能会废弃
### offsetCoordinate
{ boolean } default true
高德地图适用,是否关闭偏移坐标系
## 方法
### getZoom 获取缩放等级

View File

@ -252,7 +252,7 @@ export default class Marker extends EventEmitter {
const { color, anchor } = this.markerOption;
if (!element) {
this.defaultMarker = true;
element = DOM.create('div');
element = DOM.create('div') as HTMLDivElement;
this.markerOption.element = element;
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svg.setAttributeNS(null, 'display', 'block');
@ -274,10 +274,18 @@ export default class Marker extends EventEmitter {
element.appendChild(svg);
}
DOM.addClass(element, 'l7-marker');
Object.keys(this.markerOption.style || {}).forEach((key: string) => {
Object.keys(this.markerOption.style || {}).forEach(
// @ts-ignore
element?.style[key] = this.markerOption?.style[key];
});
(key: keyof CSSStyleDeclaration) => {
const value =
this.markerOption?.style && (this.markerOption?.style[key] as string);
if (element) {
// @ts-ignore
(element.style as CSSStyleDeclaration)[key] = value;
}
},
);
element.addEventListener('click', (e: MouseEvent) => {
this.onMapClick(e);
});

View File

@ -311,7 +311,7 @@ export default class L7MapService implements IMapService<Map> {
private handleCameraChanged = () => {
const { lat, lng } = this.map.getCenter();
const { offsetCoordinate = false } = this.config;
const { offsetCoordinate = true } = this.config;
// resync
this.viewport.syncWithMapCamera({