问题
I am currently doing some animation (smooth zooming & panning) in OpenLayers using ol.animation, but sometimes those animations are too fast to show smooth zooming (tiles do not load fast enough) - which is expected behaviour. But animation on my page starts only after viewer reads whole post (~1min), so I thought I could preload tiles that are needed for the animation in this time of inactivity.
Is there possibility to preload tiles of a layers/map? I was thinking some solutions:
- Create another view and simulate the animation behind the first layer
- Create layer/map clone behind visible one, and create animation behind in that extra time. And when animation finished, just show the pre-load map
- Call some loadTiles function depending on the tiles I want to load, but I don't know it that function exists
回答1:
It's much easier than you think - tile layers have an preload
option. So if you want to preload e.g. down to zoom level 3, you could construct your layer with
new ol.layer.Tile({
...
preload: 3
});
Also see http://openlayers.org/en/v3.4.0/apidoc/ol.layer.Tile.html.
来源:https://stackoverflow.com/questions/29748650/preload-tiles-before-animation