-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
when setView is called, _reset is called twice.
The first call is (approximately) setView --> _resetView --> (loading is true) eachLayer(layerAdd) --> onAdd --> _reset
Second call is setView --> _resetView --> (loading is false, i.e. _tilesToLoad is 0) fire 'viewreset' event --> onAdd is listening for 'viewreset' --> _reset
This means the this._tile object gets doubled down on, but the reset doesn't unbind the load event for tiles from before the first setView reset, and _tileLoaded is called twice as many times as necessary.
This is leading to an interesting error where _tilesToLoad decrements to a negative whatever the value was when setView was initially called (e.g. if tilesToLoad was 12 it would decrement to -12). The 'load' event is triggered when _tilesToLoad hits 0. If you pan around the map after the double reset, _tilesToLoad will be a negative number, and isn't reset on pan. Instead, it's assumed that _tilesToLoad is at or above 0 and increments _tilesToLoad however many tiles new tiles are in the queue (i.e. -12 + 5 = -7) so the 'load' event isn't triggered again unless _tilesToLoad manages to eek back up to above 0. This doesn't seem to affect actual tiles loading, just the event triggers.
/cc @jfirebaugh