The tileQueue might have entries again after zooming when the previous zoom level hasn't finished loading yet. Removing the check for the tileQueue's length makes layers report loadend correctly again.
layer.maxExtent is always set as soon as the layer is added to a map. Instead, making behavior consistent with tiled layers: don't display outside maxExtent except when displayOutsideMaxExtent is set to true or the layer's extent equals the world bounds for maps with a baseLayer that has wrapDateLine set to true.
The UTFGrid layer's `getTileInfo` method was not correctly handling dateline wrapping (and was a bit more complicated than it needed to be). Since it would be useful to all grid layers to be able to retrieve a tile and pixel offset for any map location, this functionality deserves to be on the Grid layer.
The WMTS layer currently exposes a `getTileInfo` method that is used within the layer and by the WMTSGetFeatureInfo control. This method could be renamed to `getRemoteTileInfo` or something to differentiate it from a method that gets locally cached tile info. Until that change is made, the method on the Grid layer will be called `getGridData`.
For this to be useful (i.e. so listeners can see/modify the tile url), a change in Tile.Image is required so we do not fire the loadstart event before we have the url to load.
No need to clone the passed bounds (read only access).
'bounds' can be either a Bounds instance or a simple javascript
object. Same for 'origin': LonLat instance or a simple javascript
object.
Since draw is the only tile operation that we defer, the tile queue can be an array of tiles and queue handling can be simplified. We now use the beforedraw event to defer drawing, and remove all occurrences of a tile from the tile queue when we draw it.
Instead of layers that want to defer tile drawing having to override the tile's draw method, layers can now abort drawing by returning false from a beforedraw listener, and later call draw(true) to draw the tile directly, without clearing it first.
This saves server requests, and because we use OpenLayers.Animation, setting img.src on a tile should not freeze iOS any more, so we can hopefully get rid of scheduleMoveGriddedTiles.
The reason is that we want to avoid moveGriddedTiles to run through hundreds of cycles to shift tiles until we reach the new bounds. But containsBounds does not work if extents that cross the date line start on different worlds, so we use intersectsBounds where we can pass the world bounds to handle this case.
When the grid crosses the dateline, the top-right tile is in a different world than the bottom-left one. Instead, use the grid size and tile width/height to calculate the top-right coordinate.