This sample demonstrates how to display a Basemap Gallery component to allow users to switch between different basemaps.
By default, the Basemap Gallery will display a list of basemaps from arcgis.com
. In an arcgis-map component, only 2D basemaps will be shown. A 3D arcgis-scene component will also include 3D basemaps, which are distinguishable with a '3D' tag. If you have a portalUrl defined, then the Basemap Gallery will display a list of basemaps defined in your Portal.
To update the list of basemaps displayed, set the source
property of the Basemap Gallery. This can either point to a different portal source, or a local list of basemaps. See Basemaps with different projections for an example defining a PortalBasemapsSource
.
To create a custom list of basemaps from local sources, source
should be set to an array of basemaps representing LocalBasemapsSource. This can include basemaps created by referencing their PortalItem, or from a well known basemap ID, as shown in the following code snippet.
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
const customBasemap = new Basemap({
portalItem: {
id: "46a87c20f09e4fc48fa3c38081e0cae6",
},
});
document.querySelector("arcgis-basemap-gallery").source = new LocalBasemapsSource({
basemaps: [Basemap.fromId("topo-vector"), Basemap.fromId("hybrid"), customBasemap],
});
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4