Adding two WFS layers to the map.

1378
6
01-12-2018 01:21 AM
Søren_BollOvergaard
New Contributor II

I've the following JS code which should present 2 WFS layers on map on the screen:

 map = new Map("map", {    basemap: "gray",    center: [16.4, 48.2],    zoom: 11,    });   esriConfig.defaults.io.proxyUrl = "/proxy/";   var url = "https://data.wien.gv.at/daten/geo";     var layer1 = new WFSLayer();  layer1.fromJson({    "url": url,    "name": "BEHINDERTENPARKPLATZOGD"  });   var layer2 = new WFSLayer();  layer2.fromJson({    "url": url,    "name": "BEZIRKSGRENZEOGD"  });   map.addLayers([layer1, layer2]);

Unfortunatelly, when I run this code in the browser - only first layer is presented on the map screen (in my case -it is: layer1). When I change the order of added layers (for example: map.addLayers([layer2, layer1])) - still only first layer is visible on the map screen ("layer2" in this case)

ArcGis JavaScript API version we're currently using is: 3.23

Any ideas?

Tags (3)
6 Replies
NiklasKöhn
Esri Contributor

Same in 3.24

0 Kudos
NiklasKöhn
Esri Contributor

The wfslayer class is marked as beta since it has been added in 3.14. Is this ever gonna change? 4.x API doesn't have a WFSLayer... yet?
More bugs in the 3.24 version of WFSLayer:

  • The "loaded" property is immediately true after using layer.fromJson(opts). We all know that this can't be correct.
  • No "load" event is fired, although the API documentation claims that an "onLoad" event is supported. That particular sentence comes with a broken link to a non-existing anchor. Someone must have copied that over from the GraphicsLayer documentation.
    => No way to tell if the layer was successfully loaded before drawing.
  • Creating a new WFSLayer doesn't work with options parameter (new WFSLayer(opts)) => no network activity. Only when using an empty constructor call and layer.fromJson(opts) afterwards, requests are fired out to the service (GetCapabilities and a call to the sublayer that is defined in the opts).

I've enhanced the WFSLayer sample with the following code, that shows all of the above mentioned problems:

var opts = {
 "url": "https://data.wien.gv.at/daten/geo",
 "version": "2.0.0",
 "name": "BEZIRKSGRENZEOGD",
 "wkid": 4326,
 "maxFeatures": 1000
 };
 var layer = new WFSLayer(opts);
 //layer.fromJson(opts);
 console.log("layer", layer.loaded, layer);
 
 layer.on("load", function(e) {
 console.log("layer loaded", e);
 })

var opts1 = {
 "url": "https://data.wien.gv.at/daten/geo",
 "version": "2.0.0",
 "name": "BOTSCHAFTOGD",
 "wkid": 4326,
 "maxFeatures": 1000
 };
 var layer1 = new WFSLayer(opts1);
 //layer1.fromJson(opts1);
 console.log("layer1", layer1.loaded, layer1);

layer1.on("load", function(e) {
 console.log("layer1 loaded", e);
 })

map.addLayer(layer1);
map.addLayer(layer);

Lloyd Heberlie Bjorn Svensson Julie Powell‌ Any news about the WFSLayer in 3.x and 4.x?

0 Kudos
AndyGup
Esri Regular Contributor

Søren Boll Overgaard I agree that doesn't sounds right. We're researching possible next steps, it may take a day or so since folks are on vacation.

Niklas Köhn‌, you'll need to go thru Redlands tech support to have those bugs fully triaged and tracked. I sent you a separate email with additional details. 

NiklasKöhn
Esri Contributor

Thanks Andy, I'll do that.

0 Kudos
AndyGup
Esri Regular Contributor

Søren Boll Overgaard‌ looks like we only plan to support one layer in 3.x WFSLayer. Is there any chance you can convert that data to a different type of layer? There's a good chance that would offer more capabilities and better performance. 

NagarajMahadevan
New Contributor

I am also trying to add more than one WFSLayer layer in 3.x and facing the same issue 

Could someone please confirm currently also, it is not supported to add more WFS layer using 3.x Escri Map ?

Note : But in arcgis online I was able to achieve it, isn't same technology used in Arcgis online ?