Question

I have an OpenLayers map with a TMS layer. For each zoom change, my map makes about 56 requests for map tiles (depending on the map/screen size). If the user rapidly zooms in or out, all these map tile requests get queued up in order, and my understanding is that the map tile requests from OpenLayers are not called asynchronously. So if a user zooms in or out rapidly, there ends up being many requests for map tiles that are no longer needed, and the ones that are needed will not load in until all previous requests are made.

Is there any way to abort pending map tile requests when the zoom changes? If not through OpenLayers, is there some way to abort all pending requests to a specific URL?

Was it helpful?

Solution

Update to OpenLayers 2.12 or above, because since this version the tile queue has been enhanced and will now avoid old requests. To cite from the OpenLayers 2.12 Release Notes:

The tiling code has been overhauled so tile loading in grid layers is now done in a queue. The tile queue gives more control on the tile requests sent to the server. Pending requests for tiles that are not needed any more (e.g. after zooming or panning) are avoided, which increases performance and reduces server load.

OTHER TIPS

When you have defined zooming by mousewheel, you can use the following code to prevent loading tiles for all intermediate zoomlevels:

new OpenLayers.Control.Navigation({
    "zoomWheelEnabled": true,
    "mouseWheelOptions": {
        "interval": 250, 
        "cumulative": true
    }
})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top