Register change listeners for loading tiles only

With this commit we register a change listener at a time when we are guaranteed that the listener will be called. In this was we don't need to remove listeners when the tile is dropped from the tile queue. And to avoid busy-polling between IDLE and LOADING we rely on the map to call requestRenderFrame when new tiles change to LOADING from IDLE.
This commit is contained in:
Éric Lemoine
2013-03-07 11:03:20 +01:00
parent 7fabff5ffa
commit f55423d575
5 changed files with 16 additions and 5 deletions

View File

@@ -391,10 +391,11 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
tileState = tile.getState();
if (tileState == ol.TileState.IDLE) {
this.listenToTileChange(tile);
this.updateWantedTiles(frameState.wantedTiles, tileSource, tileCoord);
tileCenter = tileGrid.getTileCoordCenter(tileCoord);
frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter);
} else if (tileState == ol.TileState.LOADING) {
this.listenToTileChange(tile);
} else if (tileState == ol.TileState.LOADED) {
if (mapRenderer.isTileTextureLoaded(tile)) {
tilesToDrawByZ[z][tileCoord.toString()] = tile;