I am trying to sort WebMaps layers by their portalItems tags before loading them. My goal is to be able to sort layers into groups and create a UI element where users choose to display a feature layer based on its tag before loading the layer. Here is the code that I am running.
var webmap = new WebMap({
portalItem: {
id: webmapId,
portal: portalObject,
},
}).load().then(function(tmp_map){
for(const layer of tmp_map.allLayers.items) {
if (layer.type == "feature"){
console.log("loading " + layer.title)
console.log(layer.portalItem.tags)
new FeatureLayer({...layer,
portal: portalObject,
}).load().then(feature_layer => {
feature_layer.visible = true
map.add(feature_layer)
console.log("loaded " + feature_layer.title)
console.log(feature_layer.portalItem.tags)
});
break;
}
};
});
The first two console logs output null for the tags
loading Original Design DSM Layout
null
The second two console logs output the tags as an array of strings as expected
loaded Original Design DSM Layout
Array(4) [ "TEMP", "8022", "TI", "Geotechnical Construction" ]
When looking at the request you can see that when loading the WebMap each layer gets this data:
id
layerType
url
visibility
opacity
title
itemId
showLegend
Is there a way to load the tags alongside these when loading a WebMap.