openlayers - 如何刷新openlayers中的单个图块?
问题描述
我正在尝试构建一个随时间变化的应用程序。到目前为止,我只能刷新整个图块源。但是,每当您刷新它时,整个图片都会短暂闪烁 - 图片被删除并重新绘制。但是,如果图块正在加载,则仅重绘加载新图块的部分图像。我想得到类似的行为
var Source=new ol.source.OSM({
url: 'http://localhost:900/{z}-{x}-{y}.png',
attributions:[],
wrapX: false ,
tileLoadFunction:function(imageTile, src) {var mr = Math.random(); imageTile.getImage().src = src+'?t='+mr;}
});
加上清爽:
Source.tileCache.expireCache({});
Source.tileCache.clear();
Source.refresh();
解决方案
我解决了它 - 你不能刷新整个源,而只是从缓存中删除磁贴:
function RefreshIndividual(z,x, y) {
var index= z+'-'+x+'-'+y;
var index2= z+'/'+x+'/'+(-y-1);
updateTimes[index] = new Date().getTime();
console.log(index,'t'+updateTimes[index]);
Source.tileCache.remove(index2);
Source.changed();
}
推荐阅读
- vue.js - 传递给子组件的道具在创建的方法中未定义
- c - 使用 sub/cmp/setbe 逆向工程 asm 回到 C?我的尝试是编译到分支
- javascript - JS通过点击改变内容
- javascript - 如何在javascript中将字符串中的某些部分作为组获取?
- android - ViewPager 中的项目在滑回页面时消失并重新出现
- python - 给定另一列的值,减去熊猫数据框中的连续时间帧
- javascript - 根据窗口大小改变功能
- ios - 如何检查应用程序是否已更新?
- arm - 使用硬件参考手册和配置寄存器设置中断
- javascript - 替换 onmouseover 和 onmouseout 的图像