ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Core Namespace / ArcGISPortalExtensions Class / GetBasemapsAsync Method
Example

In This Topic
    GetBasemapsAsync Method
    In This Topic
    Gets the list of base maps that are configured for the given portal.
    Syntax
    public static Task<IReadOnlyList<PortalItem>> GetBasemapsAsync( 
       ArcGISPortal portal
    )
    Public Shared Function GetBasemapsAsync( _
       ByVal portal As ArcGISPortal _
    ) As Task(Of IReadOnlyList(Of PortalItem))

    Parameters

    portal

    Return Value

    Exceptions
    ExceptionDescription
    Thrown when an invalid portal is provided as the active portal.
    Base map gallery group query was not found.
    Base map gallery group for 'baseMapGroupQuery' was not found.
    You do not have permissions to access this resource or perform this operation.
    Request failed: status code {status code}.
    Remarks
    The base maps may include vector base maps if the portal administrator has configured vector base maps as the preferred default. The base maps may also vary depending on the given user's culture.
    Example
    Get Basemaps
    //Basemaps stored locally in the project. This is usually an empty collection
    string localBasemapTypeID = "cim_map_basemap";
    var localBasemaps = await QueuedTask.Run(() =>
    {
      var mapContainer = Project.Current.GetProjectItemContainer("Map");
      return 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]));
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also