LayerInfos and App Loading

346
2
11-12-2021 09:18 AM
NathanHeickLACSD
Occasional Contributor III

I'm working on customizing a widget and I need access to all of the layers and tables in the map to clear selections.  I was imitating other parts of Web AppBuilder and using LayerInfos.  I had no problem doing this with a custom class that was probably loaded later in the application loading process.  However, this time around I am having some issues.  Here is the code I am running:

 

var layerInfosObj = LayerInfos.getInstanceSync();
var layerObjects = [];

layerInfosObj.getLayerInfoArray().forEach(function (layerInfo) {
  layerObjects.push(layerInfo.layerObject);
});

layerInfosObj.getTableInfoArray().forEach(function (tableInfo) {
  layerObjects.push(tableInfo.layerObject);
});

 

I added this code to an event handler that subscribes to app/mapLoaded.  The layer objects I get from the layers are all fully built out.  The ones from the tables are somewhat empty objects.  If I run the same code after the app is fully loaded, the layer objects for the tables are complete.  I need the layer Objects for the tables to have the clearSelection method and they don't on app/mapLoaded.

Is there another topic I could subscribe to that occurs later?  I have no idea where to find documentation on these subscription topics.  I searched for app/mapLoaded elsewhere in the code and I could not find where it is published.  Therefore, I don't know how this works.

0 Kudos
2 Replies
EricRuberson1
New Contributor III

not a great solution, but a possible work around. The esri default Splash widget has events at the bottom that publish 'splashPopupShow' and 'splashPopupHide'. So if you have a splash widget,  you could try listening to that. The user might still click through it faster than it takes to get the map stuff loaded?

Also try googling for something like 'how to find out what javascript events are running'?

https://stackoverflow.com/questions/3787555/how-to-find-out-which-javascript-events-fired

 

 

 

 

NathanHeickLACSD
Occasional Contributor III

Thanks, Eric.  I will look into that.

0 Kudos