我使用的是openlayer 4.4.0,并且我正在尝试构建一个查询来查找mapserver特性并显示多边形。
我的灵感来自于这个没有成功的例子,收集了一个错误57 (我找不到在哪里可以找到openlayer 4.4的错误)。
https://openlayers.org/en/v4.6.5/examples/vector-wfs-getfeature.html
我怎样才能正确地构建这个请求?
我尝试了这个代码,得到了错误57
var vectorSource = new ol.source.Vector();
// generate a GetFeature request
var featureRequest = new ol.format.WFS().writeGetFeature({
srsName: 'EPSG:3857',
featureNS: 'http://www.opengis.net/wfs',
featurePrefix: 'ms',
featureTypes: ['emprise'],
outputFormat: 'application/json',
filter: ol.format.filter.and(
//ol.format.filter.like('name', 'Mississippi*'),
ol.format.filter.equalTo('numope', 'FA11163001') //example numope=='FA11163001'
)
});
// then post the request and add the received features to a layer
fetch('http://10.210.1.32:8080/cgi-bin/mapserv.exe?map=C:/ms4w/map/fond_mapserver_wfs_ol4.map', {
method: 'POST',
body: new XMLSerializer().serializeToString(featureRequest)
}).then(function(response) {
return response.json();
}).then(function(json) {
var features = new ol.format.GeoJSON().readFeatures(json);
vectorSource.addFeatures(features);
//map.getView().fit(vectorSource.getExtent());
console.log ('featuresrequest',features)
});
转载请注明出处:http://www.mingyanggongyi.com/article/20230526/2240791.html