Viewer for HTML5 Feature Layer Access
Hello!
My custom module has a need to access ESRI FeatureLayers. However, when I try to get at the FeatureLayers, they cannot be used. Specifically, I am having a problem with selecting features.
Can you provide any support on getting FeatureLayer objects? The getFeatureLayer() method on the GC layer does in fact return a layer that seems like an esri FeatureLayer, but it is not fully-populated.
In other words, I don't see a way to access FeatureLayer objects for querying/selecting/field inspection since the GC Essentials Web Manager allows you to build applications that take ArcGISDynamicServiceLayer objects only.
...
initialize: function (config)
{
_vmScope = this;
this.app.eventRegistry.event("LayerAddedEvent").subscribe(this, this._onGCLayerAdded);
}
...
_onGCLayerAdded: function(serviceLayer, service)
{
var layers = service.layers;
for (var i = 0; i < layers.length; i++)
{
var layer = layers[i];
console.log("GC LAYER ACCESSED: " + layer.name);
layer.getFeatureLayer().then(function(esriLayer)
{
if (esriLayer.hasOwnProperty("type"))
{
// A FeatureLayer object can actually be of type: Table or Feature Layer.
if (esriLayer.type === "Feature Layer")
{
_vmScope._selectableLayers.push(esriLayer);
console.info("Selectable Layer Added: " + esriLayer.name);
}
}
});
}
},
...
0
-
I will answer my own question now that I have the solution! (All of the information below is using GC v 2.5.2 and its supported ESRI JS version- 10.3?). The JS API just changed documentation at the site to v 10.4 this morning.
First of all, the getFeatureLayer() method does not return the ESRI FeatureLayer. It is a GC Layer object. My code didn't work above because I'm fairly new to JavaScript, and there is a known conundrum when using callbacks (as in the function inside the then() method above) as far as evaluating the looping variables. A special auxiliary/helper method needs to be built, that when executed, actually evaluates the value of (in this case- layer), and returns the callback function. A simple google search on the conundrum should return plenty of results.
The JS ES2015 update has answered this annoyance with the let keyword. By declaring variables with let, they are scoped and evaluated instead of hoisted.
To further answer the ESRI FeatureLayer access problem-- there really does not appear to be a solution either in the ESRI framework or the GC framework as far as gaining access to FeatureLayer objects from ArcGISDynamicMapServiceLayer objects. In this case, I will need to force the administrator to add the layer as a FeatureLayer when configuring the map, instead of adding as a Map Service.0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
1 Kommentar