I'm trying to swap web maps in the same view using javascript api 4.10. I can get it to work using javascript 4.0. I'm using portal 4.5. The map will come up and I can click the second button and it will go to the second map although it is not centered like in the map viewer and when I try to click the button that opened originally... nothing happens. Please let me know what I may be doing wrong. Thanks in advance.
Below is the code:
There's a sample in the API using the latest version (4.10) that shows how to switch web maps:
Swap web maps in the same view | ArcGIS API for JavaScript 4.10
Yes Kelly, that is where I got the sample from. I just don't understand why it's not working correctly. Any thoughts?
When I run your test code locally it works for me. I just updated the url for esriConfig.portalUrl to point to https://www.arcgis.com.
Does it work for you if you comment out the esriConfig.portalUrl? Are there any errors in the developer console? Have you tried different browsers?
When I comment out the esriConfig.portalUrl it does not load anything and I get: "Failed to load portal item" in the Developer Console. No errors at all in the console when I don't have it commented out. It will load the initial view. I click on the second button and it does bring the next view up but not centered on the map(background does not change). I click back on the first button, the background doesn't change, and it does not load the initial view. Very odd.
Are you sure all the web maps you have listed are valid and accessible? You can test them by trying to open them in the online map viewer.
http://www.arcgis.com/home/item.html?id=6a8590710dd847ef967b8b45e8439bb4
Yes. They work in version 4.1.
I'm going to upgrade from 10.5 to 10.6.1 next week and see if this will have any affect.