0
已經過了3天我正在尋找解決方案,但是我沒有找到答案。在我第一次與WFS
要求工作來顯示使用update()
功能得到Dropdown list
layer
和改變cql-filter
值我的層和它的工作:使用Openlayers將update()函數添加到cql篩選器3
<select name="pam" class='pam' id="pam" onchange='update()'>
<option value="Arbuuned">Moyen</option>
<option value="Bended">Fort</option>
</select>
<script>
var vector = new ol.layer.Vector({ source: new ol.source.Vector() })
var geojsonFormat = new ol.format.GeoJSON();
var vectorSource = new ol.source.Vector({
loader: function(extent, resolution, projection) {
var url = "http://localhost:8080/geoserver/opengeo/ows?service=WFS&" +
"version=2.0.0&request=GetFeature&typename=opengeo:arbousiers0&CQL_FILTER=code_espec="+"'"+pam.value+"'"+
"&outputFormat=text/javascript&format_options=callback:loadFeatures"+
"&srsname=EPSG:3857";
$.ajax({url: url, dataType: 'jsonp', jsonp: false});
},
strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
maxZoom: 19
}))
});
window.loadFeatures = function(response) {
vectorSource.addFeatures(geojsonFormat.readFeatures(response));
};
window.update = function() {
vectorSource.clear(true);
};
</script>
但是當我決定與WMS
要求我改變工作像這樣的腳本:
var wmsSource= "code_espec="+"'"+pam.value+"'"+"";
window.update = function() {
wmsSource.clear(true);
};
new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://localhost:8080/geoserver/opengeo/wms',
params: {'LAYERS': 'opengeo:arbousiers0','cql_filter':wmsSource},
serverType: 'geoserver'
})})
我什麼也沒得到,當我選擇我的layer
從dropdown list
。我不知道是否有添加或我犯的錯誤?謝謝你
是的,它的工作兄弟,非常感謝你 – Issam