Select to view content in your preferred language

WFSLayer - Only call GetFeature when layer is visible

963
4
06-12-2019 01:43 AM
JesperMark
New Contributor

Hi all,

Our users are heavily dependent on external data from WFS's in their map, so multiple WFSLayers are created and added to the map when it is initialized. The layers are not visible by default, and only a few of the layers are shown simultaneously. It is a requirement that the mode is 'ondemand'. It turns out, that even though that most of the layers are not visible and suspended, every time the map extent is changed, a GetFeature-request is called for each of the layers added to the map. This causes performance issues when the users have many WFSLayers added to the map.

Is there a way to control this behavior and prevent all the unnecessary GetFeature calls? Loading megabytes of unused data every time the map extent is updated is not viable.

We're using ArcGis JS API 3.x

Best regards

Jesper

0 Kudos
4 Replies
JesperMark
New Contributor

Hi again,

Is the only way to avoid GetFeature calls from suspended WFSLayers to unload them from the map? I don't see any obvious ways to control it directly or indirectly from the layer object https://developers.arcgis.com/javascript/3/jsapi/wfslayer-amd.html

Best regards

Jesper

0 Kudos
DavidWilson3
Occasional Contributor

Hi Jesper,

A possible work around I have thought of that may work for you is to create a function that returns a visible layer or layers depending on your needs, then you only use GetFeature calls on those returned visible layers. Here is a quick code snippet of the getVisibleLayer() function I am suggesting:

function getVisibleLayer() {
  var layerList = [WFSLayer1, WFSLayer2, WFSLayer3];
  var visibleLayer = new WFSLayer();
  for (i = 0; i < layerList.length; i++) {
    if (layerList[i].visible == true) {
        visibleLayer = layerList[i];
     }
   }
   return visibleLayer;
 }‍‍‍‍‍‍‍‍‍‍

This example function only returns one visible layer at a time obviously but if you need to get multiple you could change it to return a list as well.

0 Kudos
JesperMark
New Contributor

Hi David

Thank you for your suggestion. The main problem here is, however, that I do not control the GetFeature call to the service. This is handled internally in the WFSLayer object and is called for instance, when the map extent is updated. This is why my initial suggestion for a workaround was to unload the whole WFSLayer from the map, when it is not visible. For that workaround, I will indeed construct a function to find the visible layers.

Best regards

Jesper

0 Kudos
JesperMark
New Contributor

For the record, the WMSLayer does not behave like this, since GetMap calls are only fired on layers that are not suspended. Therefore, I consider the unnecessary GetFeature calls of the WFSLayer to be a bug.

0 Kudos