Openlayers-3 Force map update

I have a custom style that shows / hides features on the map, but when applied, it doesn't get activated until the map is refreshed due to a feature update, but I need it to fire immediately.

I tried map.render and renderSync () but they didn't do anything. mapResize () doesn't do anything either, but if I wait for the function to update or move the map, it works.

Any ideas? How can I force the map to redraw on demand, regardless of the function update?

+3


source to share


5 answers


I believe you need to force the source of the layer to update, you can do this by calling a function on it changed

:

yourLayer.getSource().changed();

      



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

+7


source


I finally found a solution to update layer on openlayers 3.

You need to update the layer source parameters as follows:



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

      

+5


source


one way is to group your functions based on their purpose and place each group at different levels, then you can easily show or hide the specified layer that has the functions you want to hide or show.

0


source


If Sarumanatee doesn't work for you, you can try the following:

map.render();

      

I am using ol3.

0


source


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

This will definitely work.

0


source







All Articles