Openlayers-3 Force a map refresh

醉酒当歌 提交于 2019-12-04 06:35:10

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

see: http://openlayers.org/en/v3.6.0/apidoc/ol.source.Source.html

I've finally found a solution to refresh a layer on openlayers 3.

You have to update params of the layer source like this:

var source = yourLayer.getSource();
var params = source.getParams();
params.t = new Date().getMilliseconds();
source.updateParams(params);

In case Sarumanatee doesn't work for you, you can try this one:

map.render();

I am using ol3.

one way is to group your features based on their purpose and put each group on different layers, then you can easily show or hide specified layer that have the features your want to hide or show.

Use yourlayer.source().updateParams({CQL_FILTER:"1=1"});

It will definitely work.

To solve the issue just use

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