Parameters
- basemap
- A basemap.
| Exception | Description |
|---|---|
| ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
{
//Basemaps stored locally in the project. This is usually an empty collection
//Note: Needs QueuedTask to run
string localBasemapTypeID = "cim_map_basemap";
var mapContainer = Project.Current.GetProjectItemContainer("Map");
mapContainer.GetItems().Where(i => i.TypeID == localBasemapTypeID).ToList();
//portal basemaps. If there is no current active portal, the usual default
//is arcgis online
var portal = ArcGISPortalManager.Current.GetActivePortal();
var portalBaseMaps = await portal.GetBasemapsAsync();
//use one of them...local or portal...
//var map = MapView.Active.Map;
//QueuedTask.Run(() => map?.SetBasemapLayers(portalBaseMaps[0]));
}
{
//Note: Run within QueuedTask
map.SetBasemapLayers(Basemap.Gray);
}
{
//Note: Run within QueuedTask
map.SetBasemapLayers(Basemap.None);
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)