From 518b1c64b10a357e384566f73103a219256a8dde Mon Sep 17 00:00:00 2001 From: qiwei Date: Thu, 9 Nov 2023 09:42:02 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=8A=A8=E6=80=81=E6=A0=87=E8=AE=B0?= =?UTF-8?q?=E5=9B=BE=E5=B1=82=20remove=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../animate-marker/AnimateMarkerLayerViewModel.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mapboxgl/web-map/layer/animate-marker/AnimateMarkerLayerViewModel.ts b/src/mapboxgl/web-map/layer/animate-marker/AnimateMarkerLayerViewModel.ts index 1dc76f72..e80e69a2 100644 --- a/src/mapboxgl/web-map/layer/animate-marker/AnimateMarkerLayerViewModel.ts +++ b/src/mapboxgl/web-map/layer/animate-marker/AnimateMarkerLayerViewModel.ts @@ -121,11 +121,13 @@ export default class AnimateMarkerLayerViewModel extends mapboxgl.Evented { } public removed() { - if(this.map && this.map.getLayer(this.layerId)) { - this.map.removeLayer(this.layerId); - this.map.removeSource(this.layerId); + if (this.map) { + if(this.map.getLayer(this.layerId)) { + this.map.removeLayer(this.layerId); + this.map.removeSource(this.layerId); + } + this.map.off('styledata', this.updateLayerFn); } - this.map.off('styledata', this.updateLayerFn); this.markers.length > 0 && this.markers.forEach(marker => { marker && marker.remove();