fix: 修复gaodev2下MarkerLayer清除有误问题 (#1324)

* fix: markerLayer在GaodeMapV2做底图时removeMarkerLayer视图图层层级改变时会复原被删除的图层 (#1322)

去除clear方法中调用注销监听事件

* fix: 修复gaodev2下layer清除有误问题

Co-authored-by: bolry <909559682@qq.com>
Co-authored-by: Dreammy23 <echo.cmy@antgroup.com>
This commit is contained in:
Dreammy23 2022-09-07 11:44:38 +08:00 committed by GitHub
parent 58df737121
commit d4ec1ca59e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -2,14 +2,14 @@
```tsx
import { Marker, MarkerLayer, Scene } from '@antv/l7';
import { GaodeMap } from '@antv/l7-maps';
import { GaodeMapV2 } from '@antv/l7-maps';
import React, { useEffect } from 'react';
export default () => {
useEffect(() => {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
map: new GaodeMapV2({
center: [105, 30.258134],
zoom: 3,
}),
@ -43,8 +43,8 @@ export default () => {
)
.then((res) => res.json())
.then((nodes) => {
const markerLayer = new MarkerLayer();
for (let i = 0; i < 400; i++) {
const markerLayer = new MarkerLayer({ cluster: true });
for (let i = 0; i < 1000; i++) {
const { coordinates } = nodes.features[i].geometry;
const el = document.createElement('label');
el.textContent = coordinates[1];

View File

@ -160,10 +160,11 @@ export default class MarkerLayer extends EventEmitter {
clusterMarker.remove();
});
this.mapsService.off('camerachange', this.update);
this.mapsService.off('viewchange', this.update);
this.mapsService.off('camerachange', this.setContainerSize.bind(this));
this.mapsService.off('viewchange', this.setContainerSize.bind(this));
this.markers = [];
this.points=[];
this.points = [];
this.clusterMarkers = [];
}