动画前预加载图块 [英] Preload tiles before animation

查看:89
本文介绍了动画前预加载图块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在制作一些动画(使用 ol.animation ,但有时这些动画的速度太快而无法显示平滑的缩放(瓷砖加载得不够快)-这是预期的行为.但是页面上的动画只有在查看者阅读了整个帖子(〜1分钟)后才开始,所以我认为我可以在不活动的时候预加载动画所需的图块.

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:

  • 创建另一个视图并模拟第一层后面的动画
  • 在可见图层的后面创建图层/地图克隆,并创建动画 在那多余的时间里落后了.动画结束后,只需显示 预加载地图
  • 根据我要加载的图块调用一些loadTiles函数, 但我不知道该功能是否存在
  • 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

推荐答案

比您想象的要容易得多-切片图层具有preload选项.因此,如果您想预加载例如向下缩放至3级,您可以使用

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
});

另请参见 http://openlayers.org/en/v3.4.0/apidoc/ol.layer.Tile.html .

这篇关于动画前预加载图块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆