-
Notifications
You must be signed in to change notification settings - Fork 131
Open
Description
I have checked this code with OL 3.17.1 and it does work well. However, it does not work with OL 5.3.0. There are two issues.
- The way
thisis used in the code is not accurate, as it could be different within an event handler and in OL 5.3.0, they change it to something else. A better way would be to store a reference tothisand use that instead. - There is no longer a method called
unByKey(). But, they supportun()which works in OL 3.17.1 and also 5.3.0.
The improvement below fixes the code such that it works on both OL 3.17.1 and 5.3.0.
ol.TileLoader.prototype._initTileLoader = function (map) {
const _that = this;
this._map = map;
this._view = map.getView();
this._centerChangedId = this._view.on('change:center', function (e) {
_that._updateTiles();
}, this);
this._postcomposeKey = undefined;
this._resolutionChangedId = this._view.on('change:resolution', function (evt) {
_that._currentResolution = _that._view.getResolution();
if (_that._postcomposeKey) return;
_that.fire('mapZoomStart');
_that._postcomposeKey = _that._map.on('postcompose', function (evt) {
if (evt.frameState.viewState.resolution === _that._currentResolution) {
_that._updateTiles();
_that._map.un('postcompose', _that._postcomposeKey, _that);
_that._postcomposeKey = undefined;
_that.fire('mapZoomEnd');
}
}, _that);
}, this);
this._updateTiles();
};I have however not tested this for versions in between these two. There is also widespread use of unByKey() in the code, which could be replaced with un().
Metadata
Metadata
Assignees
Labels
No labels