Skip to content

Commit

Permalink
Clear marker occlusion timer on Marker#remove (#10478)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Calder authored Mar 23, 2021
1 parent 4e72078 commit af83fa8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/ui/marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export default class Marker extends Evented {
'_onUp',
'_addDragHandler',
'_onMapClick',
'_onKeyPress'
'_onKeyPress',
'_clearOcclusionTimer'
], this);

this._anchor = options && options.anchor || 'center';
Expand Down Expand Up @@ -248,6 +249,7 @@ export default class Marker extends Evented {
map.getCanvasContainer().appendChild(this._element);
map.on('move', this._update);
map.on('moveend', this._update);
map.on('remove', this._clearOcclusionTimer);
this.setDraggable(this._draggable);
this._update();

Expand Down Expand Up @@ -277,8 +279,10 @@ export default class Marker extends Evented {
this._map.off('touchend', this._onUp);
this._map.off('mousemove', this._onMove);
this._map.off('touchmove', this._onMove);
this._map.off('remove', this._clearOcclusionTimer);
delete this._map;
}
this._clearOcclusionTimer();
DOM.remove(this._element);
if (this._popup) this._popup.remove();
return this;
Expand Down Expand Up @@ -446,6 +450,13 @@ export default class Marker extends Evented {
}
}

_clearOcclusionTimer() {
if (this._occlusionTimer) {
clearTimeout(this._occlusionTimer);
this._occlusionTimer = null;
}
}

_onOcclusionTimer() {
const tr = this._map.transform;
const pos = this._pos ? this._pos.sub(this._transformedOffset()) : null;
Expand Down

0 comments on commit af83fa8

Please sign in to comment.