Sunday 27 March 2016

Reloading OpenLayers layer from GeoServer when underlying data changes?



I have a webpage that displays a GeoTIFF served via GeoServer as an OpenLayers3 ImageWMS layer. What I need is to (via a button) reload the OL3 layer after the underlying GeoTIFF changes.


I searched around, and tried


layer.dispatchChangeEvent();

on the layer in question. But the map/image isn't updated.


I have tried


1) removing the layer, constructing a new layer from the GeoTIFF and add it back using JavaScript.


2) disabling caching for the raster layer in GeoServer.


3) using layer.getSource().dispatchChangeEvent(); as suggested by @ahocevar's answer.


None solved the problem.



The only thing that works is to reload the whole webpage, in which case the map shows the new image but all states in the page is lost.


How can I reload the layer without having to reload the whole page?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...