I need to know how many features are displayed on my screen (depending on the BBOX). I read that you can do it with a WFS request and resulttype=hits but my number of features still stay the same, whatever I put in the BBOX. Here's my code :
map.on('moveend', function(evt) {
var extent = map.getView().calculateExtent(map.getSize());
console.log(extent);
var url = 'http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=getfeature&typename=aisdata:ais_vessels& outputFormat=json&format_options=callback:getJson&resulttype=hits&bbox=' + extent.join(',');
$.ajax({
url: url,
success: function(response) {
debugger;
}
});
});
And on the following picture you can see that my BBOX is changing :
http://demo.opengeo.org/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typename=topp:states&bbox=20,-100,40,-80&resulttype=hits
than thishttp://demo.opengeo.org/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typename=topp:states&bbox=20,-100,30,-80&resulttype=hits
Try to find what is different in your system.