Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Commit

Permalink
Remove listeners on layer remove, fixes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
eJuke committed Jun 20, 2018
1 parent d1e94ed commit 8cfc039
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/plugin/leaflet.canvas-markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ function layerFactory(L) {

if (this.options.pane) this.getPane().removeChild(this._canvas);
else map.getPanes().overlayPane.removeChild(this._canvas);

map.off('click', this._executeListeners, this);
map.off('mousemove', this._executeListeners, this);

map.off('moveend', this._reset, this);
map.off('resize',this._reset,this);
},

addTo: function (map) {
Expand Down Expand Up @@ -271,7 +277,7 @@ function layerFactory(L) {

var self = this;

if (!this._map) return;
if (!this._map || !this._latlngMarkers) return;
if (clear) this._context.clearRect(0, 0, this._canvas.width, this._canvas.height);

var tmp = [];
Expand Down Expand Up @@ -356,6 +362,8 @@ function layerFactory(L) {

_executeListeners: function (event) {

if (!this._markers) return;

var me = this;
var x = event.containerPoint.x;
var y = event.containerPoint.y;
Expand Down

0 comments on commit 8cfc039

Please sign in to comment.