I allow the user to draw features, and on drawend I need to make a request to my WFS service to return features.
I can get the WFS to return data based on the extent using:
let vectorSource = new VectorSource({
format: new GeoJSON(),
url: function(extent) {
return 'https://example/wfs' +
'?key=key' +
'&SERVICE=WFS' +
'&REQUEST=GetFeature' +
'&TYPENAMES=data_point' +
'&SRSNAME=urn:ogc:def:crs:EPSG::27700' +
'&BBOX=' + extent.join(',') + ',urn:ogc:def:crs:EPSG::27700';
},
strategy: bboxStrategy
});
However I cannot get these features to display despite injecting this source into the layer, and the layer onto the map.
I can get all features to display using something along the lines of:
fetch('example/wfs?key=key', {
method: 'POST',
body: new XMLSerializer().serializeToString(featureRequest)
}).then(function(response) {
return response.text();
}).then(function(gml) {
console.log(gml);
let features = new GML().readFeatures(gml);
vectorSource.addFeatures(features);
map.getView().fit(vectorSource.getExtent());
});
However I cannot for the life of me work out how to restrict the data requested in this request to a bounding box of say four coordinates.
Potentially this could be a limitless pointed geometry that will act as a cookie cutter for data displayed.
My searches have yielded no results.