Skip to content

Commit

Permalink
fix exception in mouse event handler with empty CanvasMarkerLayer
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
johndoe committed May 7, 2019
1 parent 5b67c61 commit 6a81b9c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/plugin/leaflet.canvas-markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ function layerFactory(L) {
return this;
},
_onClick: function (e) {
if (!this._markers) { return; }

var self = this;
var point = e.containerPoint;

Expand All @@ -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);
Expand Down

0 comments on commit 6a81b9c

Please sign in to comment.