Public Shared Function GetBasemapsAsync( _ ByVal portal As ArcGISPortal _ ) As Task(Of IReadOnlyList(Of PortalItem))
public static Task<IReadOnlyList<PortalItem>> GetBasemapsAsync( ArcGISPortal portal )
Parameters
- portal
Public Shared Function GetBasemapsAsync( _ ByVal portal As ArcGISPortal _ ) As Task(Of IReadOnlyList(Of PortalItem))
public static Task<IReadOnlyList<PortalItem>> GetBasemapsAsync( ArcGISPortal portal )
| Exception | Description |
|---|---|
| PortalConnectionDoesNotExistsException | Thrown when an invalid portal is provided as the active portal. |
| System.InvalidOperationException | Base map gallery group query was not found. |
| System.InvalidOperationException | Base map gallery group for 'baseMapGroupQuery' was not found. |
| System.Net.Http.HttpRequestException | You do not have permissions to access this resource or perform this operation. |
| System.Net.Http.HttpRequestException | Request failed: status code {status code}. |
{
//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]));
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)