BasemapsController
The basemaps controller allows you to manage the map's basemap layer.
You can get the current basemap, list available basemaps, change the basemap, and be notified when the basemap changes.
Extended by
Methods
getCurrentBasemap()
getCurrentBasemap():
Promise<Basemap>
Gets the currently active basemap.
Use this method to retrieve information about the current basemap, including its type (Felt, color, or custom tile), name, color scheme, and attribution.
Returns
Promise<Basemap>
A promise that resolves to the current basemap configuration.
Example
getBasemaps()
getBasemaps():
Promise<Basemap[]>
Gets all basemaps available on the map.
Use this method to retrieve a list of all available basemaps that can be applied to the map.
Returns
Promise<Basemap[]>
A promise that resolves to all basemaps available on the map.
Example
chooseBasemap()
chooseBasemap(
id:string):void
Chooses the basemap to use for the map.
Use this method to change the current basemap. The basemap ID can be obtained from getBasemaps().
Parameters
id
string
Returns
void
A promise that resolves when the basemap has been set.
Example
addCustomBasemap()
addCustomBasemap(
args: {basemap:ColorBasemapInput|CustomTileBasemapInput;select:boolean; }):Promise<Basemap>
Adds a custom basemap to the map. This can be either a solid color or a basemap from a custom tile URL.
Parameters
args.select?
boolean
Whether to select the basemap after adding it.
Returns
Promise<Basemap>
A promise for the added basemap.
Example
removeBasemap()
removeBasemap(
id:string):Promise<void>
Removes a basemap from the list of available basemaps.
Parameters
id
string
Returns
Promise<void>
A promise that resolves when the basemap has been removed.
Events
onBasemapChange()
onBasemapChange(
args: {handler: (basemap:Basemap) =>void; }):VoidFunction
Adds a listener for when the basemap changes.
Use this to react to basemap changes, such as updating your UI or adjusting other map elements to match the new basemap's color scheme.
Parameters
Returns
VoidFunction
A function to unsubscribe from the listener.
Example
Last updated
Was this helpful?