From 88456d55e4d13ec63f7262fa7a13a9829b3b6c34 Mon Sep 17 00:00:00 2001 From: Ceremony <5873369+Ceremony64@users.noreply.github.com> Date: Wed, 3 Aug 2022 17:30:13 +0200 Subject: [PATCH] Check whether measurements before removing them This should fix issue #43 --- leaflet-measure-path.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/leaflet-measure-path.js b/leaflet-measure-path.js index 9477c8f..c59dbb6 100644 --- a/leaflet-measure-path.js +++ b/leaflet-measure-path.js @@ -228,11 +228,9 @@ }, hideMeasurements: function() { - if (!this._map) return this; + if (!this._map || !this._measurementLayer) return this; this._map.off('zoomend', this.updateMeasurements, this); - - if (!this._measurementLayer) return this; this._map.removeLayer(this._measurementLayer); this._measurementLayer = null; @@ -365,11 +363,9 @@ }, hideMeasurements: function() { - if (!this._map) return this; + if (!this._map || !this._measurementLayer) return this; this._map.on('zoomend', this.updateMeasurements, this); - - if (!this._measurementLayer) return this; this._map.removeLayer(this._measurementLayer); this._measurementLayer = null;