While creating web applications to aid our Disaster Response program, we noticed some commonly used mapping elements that didn’t exist outside of our templates. In order to save others development time and effort, we converted them to widgets and put them in the API.
Need an easy way to switch back and forth between two different basemaps on a map? The BasemapToggle provides a simple button that alternates between two basemaps. A thumbnail and a label are used to show the alternate basemap.
Have you ever navigated around a map, found yourself lost and wanted to get back to where you started? The HomeButton widget is a simple button that captures the initial extent (bounding box) of a map and allows the user to go back to that extent at any time. If your app has users exploring multiple areas this may be a helpful widget for them.
The LocateButton uses browser’s Geolocation API to center the map at the user’s location and sets the map’s scale according to the accuracy of the value returned. This is helpful if your app frequently used on mobile or users will commonly use your mapping app to view their position. It requires a modern web browser.
Last but not least, the LayerSwipe widget allows you to reveal part of a layer(s) over a map by dragging a handle on the widget. You may have experienced one of these tools using the Storytelling Swipe template or in a map on Smithsonian.com. You can swipe one or more layers horizontally, vertically or using a scope tool by dragging.