Hi, I have made use of the selectdijit and I know I need to pass in a feature layer as a param so it knows what to select from.
I just cant work out how to get my feature layers into a var to pass in, seems like it should be simple but I cant quite find out how to do it.
In all the examples I see they are creating the feature layer then adding it to the map so they already have the feature layer to pass about. As Im using WAB I am not creating the feature layers in code they are added to the map when we config the app. How do I get the feature layers in my map so I can pass them as arguments etc?
thanks
Solved! Go to Solution.
James,
If you look at the API Reference you will see that the LayerNode has a getLayerObject() method this is the actual layer object that can be passed.
LayerNode class—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS for Developers
James,
In WAB you use code like this to traverse the maps layers.
define([
...
'jimu/LayerInfos/LayerInfos',
'dojo/_base/array',
...
],
function(
...
LayerInfos, array,
...
) {
// Get all feature layers from the map
LayerInfos.getInstance(this.map, this.map.itemInfo)
.then(lang.hitch(this, function(layerInfosObj) {
var infos = layerInfosObj.getLayerInfoArray();
var options = [];
array.forEach(infos, function(info) {
console.info(info);
if(info.title === 'the title of the layer as seen in the layerlist widget') {
}
});
}));
Thanks Robert I have seen code similar to this and I have used it to print out my layer structure in the console. I have also took a look at layerStructure as layerInfos is depreciating.
Im still slightly confused as to what I pass into the dijit, it requireds a FeatuerLayer, does the resulting LayerInfos contain the featuerlayers that I can pass in or just the info about them? how can get a feature layer to pass into the dijit from this?
Heres the code I have so far that prints my layers to the console, uses layerstructure instead of layerinfos but I assume they are similar.
var layerStructure = new LayerStructure.getInstance();
console.log(layerStructure);
this._printLayerTree(layerStructure);
_printLayerTree: function(layerStructure) {
layerStructure.traversal(function(layerNode) {
var indent = "";
for(var i = 0; i < layerNode.getNodeLevel(); i++) {indent += " ";}
console.log(indent, layerNode.title);
});
},
Im trying to pass 3 feature layers into FeatureSetChooserForMultipleLayers dijit.
James,
If you look at the API Reference you will see that the LayerNode has a getLayerObject() method this is the actual layer object that can be passed.
LayerNode class—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS for Developers
thanks I will take a look at that