From 419b1abe77740418965aee0250414f2fc8cb4486 Mon Sep 17 00:00:00 2001 From: Alexander Danilov Date: Sun, 28 Apr 2019 22:46:52 +0300 Subject: [PATCH] Additional checks to prevent errors during atypical use --- src/plugin/leaflet.canvas-markers.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugin/leaflet.canvas-markers.js b/src/plugin/leaflet.canvas-markers.js index 1a9ca89..3c611c1 100644 --- a/src/plugin/leaflet.canvas-markers.js +++ b/src/plugin/leaflet.canvas-markers.js @@ -265,7 +265,8 @@ function layerFactory(L) { ); }, _searchPoints: function (point) { - return this._markers.search({ minX: point.x, minY: point.y, maxX: point.x, maxY: point.y }); + if (this._markers) + return this._markers.search({ minX: point.x, minY: point.y, maxX: point.x, maxY: point.y }); }, on: function (event, func) { var self = this; @@ -529,8 +530,10 @@ function layerFactory(L) { }, _removeGeneric: function (val, compareFn) { - this._latlngMarkers.remove(val, compareFn); - this._latlngMarkers.total--; + if (this._latlngMarkers) { + this._latlngMarkers.remove(val, compareFn); + this._latlngMarkers.total--; + } }, addTo: function (map) { map.addLayer(this);