Custom basemap toggle widget for two basemaps (Experience Builder Developer Edition)

540
2
03-07-2023 10:11 AM
ClaytonONeill
New Contributor

Hello!

My team is developing an application with Experience Builder that should allow users to toggle between two basemap options, Human Geography and Imagery.  The provided Basemap Gallery map tool offers too many basemaps to choose from, so we have begun to explore creating a custom widget to accomplish a two basemap toggle.  Something along the lines of the Basemap Toggle Widget that is available within the Javascript API would be ideal.

For further context, the solutions about creating a custom group to limit the basemaps in the gallery widget offered in the linked post at the bottom are not possible in our situation due to restrictions of our environment.

My questions are:

- Is it even possible to create a custom widget that allows users to toggle between two basemaps within an experience?

- If it is possible, would I be able to get any guidance on how to implement that functionality within a custom widget.  In the linked post, it was suggested that you could import the Basemap Gallery widget which I assume was in reference to the Basemap Gallery widget imported from @ArcGIS/core, but there was no additional information to confirm that assumption or if you can use widgets from the Javascript API inside of a custom widget.

Any help would be greatly appreciated,

Thank you!

Post: https://community.esri.com/t5/arcgis-experience-builder-questions/configure-basemaps-in-experience-b...

0 Kudos
2 Replies
BuffaloCoWI
Occasional Contributor

I have been trying to do something similar. It's especially frustrating since Instant Apps already has such a Basemap Toggle, which you can also reposition on the map in Instant Apps.

I wish Instant Apps and Experience Builder shared more functionality, since they're both based on the 4.x JS SDK, or if you could create a prototype in Instant Apps, then open it in Experience Builder for fine tuning.

After reading this and other posts, it appears I'll need to install the Experience Builder Developer Edition, which kind of defeats the purpose of using ArcGIS Online.

0 Kudos
BuffaloCoWI
Occasional Contributor

I figured out a sneaky way to do it if you only need to view the map, and not interact with any layers in it. This presentation shows that you can add up to two maps to the map widget. If you have two maps added, it automatically includes a switcher between them. Therefore, if you duplicate the map you want, but use a different basemap, it will appear as wanted. However, I also want to interact with the layers in the maps, which will only work for one of them. For example, I have a Feature Info widget to show the popup information. It can only use one source, so clicking on the map when that source is active works. Clicking on the map when switched to the other map will select the same feature, since they're duplicate maps besides the basemap, but won't affect the Feature Info widget, or presumably any other widgets. I suppose I could just leave popups enabled in the map widget, but they still can't automatically be opened by search; that's why I was using the Feature Info widget.

0 Kudos