Hello,
I've developed a custom application and have deployed it to one of our environments, but now running into issues. I need to be able to programmatically select the webmap used in the experience based on my config file, hopefully with a webmap Id. I know how to do this through creating a setting in the UI of developer, but need this to be done via code. Any help would be great!
-Derek
hey Derek, good question, changing webmap id at runtime wasnt a easy task. I have managed to test out different approach in the last 2 years thanks to the help from Jun Shan and I will try to summarize it down here.
First you need an event to trigger the webmap id change or a "SwitchMap" widget, or url hash param.
Using url hash param should be available since last year and probably would be the easiest way to do so.
Option 1
Then you need to create all the child DataSources recursively for the web map ds.
use redux actions to dispatch appConfigChanged()
then you have to uldate the MapJson too.
Yes its a long process.. and this is not the end. Lots of the "analytics" type of data, Table, Select, AddData wont immediately recognise the map change so you need to do further more, and yes I have tried to make it all works.. e.g updating table widget column, DS data schema all that ( cant remember the details of my head)
Option 2
Ultimately if you dosent have a strong reason to not reload, update the URL hash param and reload.
Thumbs of rule on how to dive deep on widget behaviour, go to the builder mode - replicate the action that you want to do - in this case change mapID. then see how the widget trigger other events.
Hope it helps.
Edward Wong
Eagle Technology, ESRI Distributor for New Zealand and South Pacific