From 258ad34d98d414d64d3f9cd391c740c1e762421a Mon Sep 17 00:00:00 2001 From: Alexander Danilov Date: Sun, 28 Apr 2019 22:45:17 +0300 Subject: [PATCH 1/5] Fix typo --- src/plugin/leaflet.canvas-markers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugin/leaflet.canvas-markers.js b/src/plugin/leaflet.canvas-markers.js index 315f50d..f63280f 100644 --- a/src/plugin/leaflet.canvas-markers.js +++ b/src/plugin/leaflet.canvas-markers.js @@ -375,7 +375,7 @@ function layerFactory(L) { for (var i = 0; i < keys.length; i++) { if (groupID === keys[0]) { var add = true; - greak; + break; } } if (!add) @@ -564,7 +564,7 @@ function layerFactory(L) { var adj_x = iconSize[0] / 2; var adj_y = iconSize[1] / 2; - var anchor_y = + var ret = [({ minX: (pointPos.x - adj_x), minY: (pointPos.y - adj_y), From 5b67c61a92150ebc4ed08102b7d1592a6e7abe00 Mon Sep 17 00:00:00 2001 From: johndoe Date: Wed, 1 May 2019 12:45:50 +0300 Subject: [PATCH 2/5] fix broken removeMarker --- src/plugin/leaflet.canvas-markers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin/leaflet.canvas-markers.js b/src/plugin/leaflet.canvas-markers.js index f63280f..bed82ed 100644 --- a/src/plugin/leaflet.canvas-markers.js +++ b/src/plugin/leaflet.canvas-markers.js @@ -521,7 +521,7 @@ function layerFactory(L) { data: marker }; - this._removeGeneric(marker, fn); + this._removeGeneric(val, fn); if (isDisplaying === true && redraw === true) { self._redraw(); From 6a81b9cf7dbfb0fc0f2754931cc8d24618806bb6 Mon Sep 17 00:00:00 2001 From: johndoe Date: Wed, 1 May 2019 18:09:19 +0300 Subject: [PATCH 3/5] fix exception in mouse event handler with empty CanvasMarkerLayer `this._markers` is undefined in `_searchPoints`, called from event listeners. Now we check markers existence in the beginning of handlers. Note 1: Could be fixed in some another place: e.g. check `_markers` in `_searchPoints` ...or initialize (empty) `_markers` on CanvasMarkerLayer init Note 2: `!this._map` removed from condition in `_onMouseMove:` 'cause it's never should be true as we detach listeners on remove from map --- src/plugin/leaflet.canvas-markers.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugin/leaflet.canvas-markers.js b/src/plugin/leaflet.canvas-markers.js index bed82ed..ec34655 100644 --- a/src/plugin/leaflet.canvas-markers.js +++ b/src/plugin/leaflet.canvas-markers.js @@ -278,6 +278,8 @@ function layerFactory(L) { return this; }, _onClick: function (e) { + if (!this._markers) { return; } + var self = this; var point = e.containerPoint; @@ -298,7 +300,7 @@ function layerFactory(L) { } }, _onMouseMove: function (e) { - if (!this._map || this._map.dragging.moving() || this._map._animatingZoom) { return; } + if (!this._markers || this._map.dragging.moving() || this._map._animatingZoom) { return; } var point = e.containerPoint; this._handleMouseHover(e, point); From ab64e182a15607424d46a6829dc82d42480fd5f3 Mon Sep 17 00:00:00 2001 From: johndoe Date: Sat, 11 May 2019 18:57:58 +0300 Subject: [PATCH 4/5] removeMarker: fix exception when CanvasMarkerLayer is not attached to map --- src/plugin/leaflet.canvas-markers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin/leaflet.canvas-markers.js b/src/plugin/leaflet.canvas-markers.js index ec34655..b643019 100644 --- a/src/plugin/leaflet.canvas-markers.js +++ b/src/plugin/leaflet.canvas-markers.js @@ -514,7 +514,7 @@ function layerFactory(L) { if (marker["minX"]) marker = marker.data; var latlng = marker.getLatLng(); - var isDisplaying = self._map.getBounds().contains(latlng); + var isDisplaying = self._map && self._map.getBounds().contains(latlng); var val = { minX: latlng.lng, minY: latlng.lat, From 4ade87994a021d5e4ac9bdfdacd538f415f531e1 Mon Sep 17 00:00:00 2001 From: johndoe Date: Sun, 12 May 2019 15:41:26 +0300 Subject: [PATCH 5/5] fix exception if image is not loaded (yet) / bad url / etc Was protected in marker add time, but not on zoom/pan Sample: ``` VM2992:16252 Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state. at NewClass._drawImage (:16252:23) at NewClass._drawMarker (:16239:22) at :16200:22 at Array.forEach () at NewClass._draw (:16179:16) at NewClass._redraw (:16077:18) at NewClass.fire (:1867:11) at NewClass._move (:5506:9) at NewClass._onZoomTransitionEnd (:5963:8) ``` --- src/plugin/leaflet.canvas-markers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin/leaflet.canvas-markers.js b/src/plugin/leaflet.canvas-markers.js index b643019..eba2525 100644 --- a/src/plugin/leaflet.canvas-markers.js +++ b/src/plugin/leaflet.canvas-markers.js @@ -245,7 +245,7 @@ function layerFactory(L) { }); } } - } else { + } else if (self._imageLookup[marker.options.icon.options.iconUrl][1]) { // image may be not loaded / bad url self._drawImage(marker, pointPos); } },