Preload tiles before animation

大憨熊 提交于 2020-01-23 03:22:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!