简体   繁体   English

OpenLayers3:如何从GeoServer重新加载图层?

[英]OpenLayers3: How to reload a layer from GeoServer?

I have a webpage that displays a GeoTIFF served via GeoServer as an OpenLayers3 ImageWMS . 我有一个网页,显示通过GeoServer作为OpenLayers3 ImageWMS服务的GeoTIFF。 What I need is to (via a button) reload the OL3 layer after the underlying GeoTIFF changes. 我需要的是在基础的GeoTIFF更改后(通过按钮)重新加载OL3层。

I searched around, and tried 我四处搜寻,并尝试

layer.dispatchChangeEvent();

on the layer in question. 在有关图层上。 But the map/image isn't updated. 但是地图/图像没有更新。

I have also tried removing the layer, constructing a new layer and add it back. 我还尝试过删除该层,构造一个新层并将其添加回去。 It didn't work either. 它也不起作用。

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. 唯一有效的方法是重新加载整个网页,在这种情况下,地图会显示新图像,但页面中的所有状态都会丢失。

My question is 我的问题是

How can I reload the layer without having to reload the whole page? 如何重新加载图层而不必重新加载整个页面?

Thanks 谢谢

To reload data from the server (ie the source), you have to call 要从服务器(即源)重新加载数据,您必须调用

layer.getSource().dispatchChangeEvent();

in v3.0.0. 在v3.0.0中。 Note that current master and the upcoming v3.1.0 version use 请注意,当前的主版本和即将发布的v3.1.0版本将使用

layer.getSource().changed();

instead. 代替。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM