2
votes

I tried to visualize parcels in wfs with openlayers 4 (max 1000) with this code. But the extent does not change at each movement or zoom of the view map, or the new features do not load in the layer?

 var parcellaireSource =  new ol.source.Vector({ 
    format: new ol.format.GeoJSON(),
    url: function (extent) {
      return  'https://wxs.ign.fr/api key/geoportail/wfs?request=GetCapabilities&SERVICE=WFS&VERSION=2.0.0&request=GetFeature&typename=BDPARCELLAIRE-VECTEUR_WLD_BDD_WGS84G:parcelle&outputFormat=application/json&srsname=EPSG:2154&bbox='+ extent.join(',') + ',EPSG:3857';

          },

    strategy: ol.loadingstrategy.bbox
    });
     var parcellairewfs =  new ol.layer.Vector({
    source: parcellaireSource
  });
     map.addLayer(parcellairewfs);
2
It works know when I ad function onMoveEnd(evt) { parcellaireSource.clear() console.log(view.getResolution()); console.log(parcellaireSource); } map.on('moveend', onMoveEnd); But, because of the number of features limit, I want to load them only on a certain zoom level. Do you see how to do it ? - ericire

2 Answers

2
votes

It works know when I add

function onMoveEnd(evt) { parcellaireSource.clear() } map.on('moveend', onMoveEnd);

But, because of the number of features limit, I want to load them only on a certain zoom level. Do you see how to do it ?

2
votes

It's done with

  url: function (extent,resolution) {if (resolution<1) {return ....

in the vectorsource calculation and adding resolution parameter to the function