Openlayers-3强制刷新地图 [英] Openlayers-3 Force a map refresh

查看:2691
本文介绍了Openlayers-3强制刷新地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义样式,可在地图上显示/隐藏地图项,但是应用地图样式后,直到由于功能更新而刷新地图时,该样式才会激活,但是我需要它立即触发.

I have a custom styling that shows/hides features on the map, but when it is applied it doesn't activate until the map refreshes due to a feature update, but I need it to trigger immediately.

我尝试了map.render和renderSync(),但是它们什么也没做. mapResize()似乎也没有执行任何操作,但是如果我等待功能更新或移动地图,它将起作用.

I tried map.render and renderSync() but they did nothing. mapResize() doesn't appear to do anything either, but if I wait for a feature to be updated or move the map it works.

有什么想法吗?无论功能更新如何,我如何强制地图按需重绘?

Any ideas? How can I FORCE the map to redraw on demand, regardless of a feature update?

推荐答案

我相信您需要强制图层的源进行更新,可以通过在其上调用changed函数来做到这一点:

I believe you need to force your layer's source to update, you can do so by calling the changed function on it:

yourLayer.getSource().changed();

请参阅: http://openlayers.org/en/v3.6.0/apidoc/ol.source.Source.html

这篇关于Openlayers-3强制刷新地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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