如何从OpenLayers的WMS层请求特定数据

问题描述 投票:0回答:1

我是Openlayers / Geoserver上的新手,我试图添加一个面板,在该面板上我可以更改“价格”,“区域大小”等设置,并仅显示符合HTML页面中给出的信息的数据。

我已经可以在TileWMS参数中使用:'cql_filter':'sterr

我也想知道这是否是实现即时尝试的好方法?

[编辑]我添加了一些我的代码index.js的屏幕截图,在这里我希望能够更改cql_filter参数index.js

这里是我的index.html,格式为index.html

我最后想要的是一个面板,用户可以在其中更改值并获取所有特定数据(这里我们有50m²至200m²之间的公寓)index.html

openlayers cql geoserver
1个回答
0
投票

您可以做这样的事情,

index.html-以此更改表格,只是为了使其简单

Min:<br>
<input id="rmin" type="number" value="50">
<br>
Max:<br>
<input id="rmax" type="number" value="200">
<br><br>
<button onclick="update()">Update Layer</button>

index.js-添加更新功能

var update = function() {
  var rmin = Number(document.getElementById('rmin').value);
  var rmax = Number(document.getElementById('rmax').value);
  mutnimesSource.updateParams({
    'LAYERS': 'ocimutnimes',
    'TILED': true,
    'cql_filter': `sterr BETWEEN ${rmin} AND ${rmax}`
  });
  console.log(rmin + ' - ' + rmax);
}
© www.soinside.com 2019 - 2024. All rights reserved.