Click or drag to resize

Basemap Class

Represents the base map part of a Map.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.MappingBasemap

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
Syntax
[ContentPropertyAttribute("BaseLayers")]
public class Basemap : INotifyPropertyChanged, IApiKeyResource, 
	ILoadable

The Basemap type exposes the following members.

Constructors
  NameDescription
Public methodBasemap
Initializes a new instance of the Basemap class.
Public methodCode exampleBasemap(Uri)
Initializes a new instance of the Basemap class with a Uri to a portal item which is a web base map.
Public methodCode exampleBasemap(BasemapStyle)
Initializes a new instance of the Basemap class with a basemap style.
Public methodBasemap(Item)
Initializes a new instance of the Basemap class with an ArcGIS Item.
Public methodCode exampleBasemap(Layer)
Initializes a new instance of the Basemap class with the specified layer.
Public methodBasemap(IEnumerableLayer, IEnumerableLayer)
Initializes a new instance of the Basemap class with a set of predefined layers.
Top
Properties
  NameDescription
Public propertyApiKey
Gets or sets the API key to access API key enabled services and resources in ArcGIS Online.
Public propertyCode exampleBaseLayers
Gets or sets the base layers of the base map.
Public propertyCredential
Gets or sets the Credential used to access a remote service.
Public propertyItem
Gets the ArcGIS Item
Public propertyLoadError
Gets the load error for this instance - if any.
Public propertyLoadStatus
Gets the load status of the instance.
Public propertyName
Gets or sets the name of the base map.
Public propertyReferenceLayers
Gets or sets the reference layers displayed on top of the OperationalLayers.
Public propertyUri
Gets the basemap's uri origin.
Top
Methods
  NameDescription
Public methodCancelLoad
Cancels an ongoing load.
Public methodClone
Clones this instance of Basemap and its members.
Public methodStatic memberCreateDarkGrayCanvasVector
Creates a dark gray canvas vector basemap.
Public methodStatic memberCode exampleCreateImagery
Creates an imagery basemap.
Public methodStatic memberCode exampleCreateImageryWithLabels
Creates an imagery basemap with labels on top.
Public methodStatic memberCreateImageryWithLabelsVector
Creates a hybrid imagery basemap with vector labels on top.
Public methodStatic memberCode exampleCreateLightGrayCanvas
Creates a light gray canvas basemap.
Public methodStatic memberCode exampleCreateLightGrayCanvasVector
Creates a light gray canvas vector basemap.
Public methodStatic memberCreateNationalGeographic
Creates a National Geographic basemap.
Public methodStatic memberCreateNavigationVector
Creates a vector basemap optimized for navigation.
Public methodStatic memberCode exampleCreateOceans
Creates an oceans basemap.
Public methodStatic memberCreateOpenStreetMap
Creates a basemap with an Open Street Map layer.
Public methodStatic memberCode exampleCreateStreets
Creates a streets basemap.
Public methodStatic memberCreateStreetsNightVector
Creates a streets vector basemap optimized for night usage.
Public methodStatic memberCreateStreetsVector
Creates a streets vector basemap.
Public methodStatic memberCode exampleCreateStreetsWithReliefVector
Creates a hybrid streets vector basemap with a relief background.
Public methodStatic memberCreateTerrainWithLabels
Creates a labeled terrain basemap.
Public methodStatic memberCreateTerrainWithLabelsVector
Creates a labeled terrain vector basemap.
Public methodStatic memberCode exampleCreateTopographic
Creates a topographic basemap.
Public methodStatic memberCreateTopographicVector
Creates a topographic vector basemap.
Public methodStatic memberFromJson
Creates a base map from the json.
Public methodLoadAsync
Initiates loading of a basemap
Public methodStatic memberLoadFromUriAsync
Load a base map from a uri resource
Protected methodOnPropertyChanged
Raises the PropertyChanged event with the provided arguments.
Public methodRetryLoadAsync
Retry loading metadata for the instance in case of a load error.
Public methodToJson
Serializes the base map to json.
Top
Events
  NameDescription
Public eventLoaded
Occurs when this instance is loaded.
Public eventLoadStatusChanged
Occurs when the instance's LoadStatus has changed.
Public eventPropertyChanged
Occurs when a property value changes.
Top
Remarks
Typically, you will use one basemap layer that is drawn beneath all other layers, but you can also add a reference layer on top of all other layers to depict boundaries, labels, or a road network. In order to take advantage of geographically load-balanced services and monitor usage with API keys or named users, use BasemapStyle.
Examples

WPF

Example Name: ChangeBasemap

Change a map's basemap. A basemap is beneath all layers on a `Map` and is used to provide visual reference for the operational layers.

Code example screen shot.

C#
// Copyright 2021 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Mapping;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Controls;

namespace ArcGISRuntime.WPF.Samples.ChangeBasemap
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Change basemap",
        category: "Map",
        description: "Change a map's basemap. A basemap is beneath all layers on a `Map` and is used to provide visual reference for the operational layers.",
        instructions: "Use the drop down menu to select the active basemap from the list of available basemaps.",
        tags: new[] { "basemap", "map" })]
    public partial class ChangeBasemap
    {
        // Dictionary that associates names with basemaps.
        private readonly Dictionary<string, Basemap> _basemapOptions = new Dictionary<string, Basemap>()
        {
            {"Streets", new Basemap(BasemapStyle.ArcGISStreets)},
            {"Streets - Night", new Basemap(BasemapStyle.ArcGISStreetsNight)},
            {"Imagery", new Basemap(BasemapStyle.ArcGISImageryStandard)},
            {"Imagery with Labels", new Basemap(BasemapStyle.ArcGISImagery)},
            {"Dark Gray Canvas", new Basemap(BasemapStyle.ArcGISDarkGray)},
            {"Light Gray Canvas", new Basemap(BasemapStyle.ArcGISLightGray)},
            {"Navigation", new Basemap(BasemapStyle.ArcGISNavigation)},
            {"OpenStreetMap", new Basemap(BasemapStyle.OSMStandard)}
        };

        public ChangeBasemap()
        {
            InitializeComponent();

            // Create the UI, setup the control references and execute initialization
            Initialize();
        }

        private void Initialize()
        {
            // Assign a new map to the MapView
            MyMapView.Map = new Map(_basemapOptions.Values.First());

            // Set basemap titles as a items source
            BasemapChooser.ItemsSource = _basemapOptions.Keys;

            // Show the first basemap in the list
            BasemapChooser.SelectedIndex = 0;
        }

        private void OnBasemapChooserSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Get the title of the selected basemap
            string selectedBasemapTitle = e.AddedItems[0].ToString();

            // Retrieve the basemap from the dictionary
            MyMapView.Map.Basemap = _basemapOptions[selectedBasemapTitle];
        }
    }
}
XAML
<UserControl x:Class="ArcGISRuntime.WPF.Samples.ChangeBasemap.ChangeBasemap"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <Grid>
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <StackPanel>
                <TextBlock Text="Select basemap"
                           FontWeight="SemiBold"
                           HorizontalAlignment="Center"
                           Margin="0,0,0,5"
                           TextWrapping="Wrap" />
                <ComboBox x:Name="BasemapChooser"
                          SelectionChanged="OnBasemapChooserSelectionChanged" />
            </StackPanel>
        </Border>
    </Grid>
</UserControl>
See Also
Additional Examples
Hyperlink to ExampleDescription
AnimateImageOverlayAnimate a series of images with an image overlay.
ArcGISMapImageLayerUrlAdd an ArcGIS Map Image Layer from a URL to a map.
ArcGISTiledLayerUrlLoad an ArcGIS tiled layer from a URL.
ArcGISVectorTiledLayerUrlLoad an ArcGIS Vector Tiled Layer from a URL.
AuthorMapCreate and save a map as an ArcGIS `PortalItem` (i.e. web map).
BufferListGenerate multiple individual buffers or a single unioned buffer around multiple points.
ChangeBasemapChange a map's basemap. A basemap is beneath all layers on a `Map` and is used to provide visual reference for the operational layers.
ChangeBlendRendererBlend a hillshade with a raster by specifying the elevation data. The resulting raster looks similar to the original raster, but with some terrain shading, giving it a textured look.
ChangeSublayerVisibilityChange the visibility of sublayers.
ChooseCameraControllerControl the behavior of the camera in a scene.
ClipGeometryClip a geometry with another geometry.
DisplayKmlDisplay KML from a URL, portal item, or local KML file.
DisplayKmlNetworkLinksDisplay a file with a KML network link, including displaying any network link control messages at launch.
DisplaySceneDisplay a scene with a terrain surface and some imagery.
EditAndSyncFeaturesSynchronize offline edits with a feature service.
ExportTilesDownload tiles to a local tile cache file stored on the device.
GenerateGeodatabaseGenerate a local geodatabase from an online feature service.
GenerateOfflineMapWithOverridesTake a web map offline with additional options for each layer.
GeoViewSyncKeep the view points of two views (e.g. MapView and SceneView) synchronized with each other.
GetElevationAtPointGet the elevation for a given point on a surface in a scene.
LineOfSightGeoElementShow a line of sight between two moving objects.
ListKmlContentsList the contents of a KML file.
LoadWebTiledLayerDisplay a tiled web layer.
LocalServerFeatureLayerStart a local feature service and display its features in a map.
LocalServerGeoprocessingCreate contour lines from local raster data using a local geoprocessing package `.gpk` and the contour geoprocessing tool.
LocalServerMapImageLayerStart the Local Server and Local Map Service, create an ArcGIS Map Image Layer from the Local Map Service, and add it to a map.
OfflineGeocodeGeocode addresses to locations and reverse geocode locations to addresses offline.
OfflineRoutingSolve a route on-the-fly using offline data.
OpenStreetMapLayerAdd OpenStreetMap as a basemap layer.
RasterRenderingRuleDisplay a raster on a map and apply different rendering rules to that raster.
SceneLayerUrlDisplay an ArcGIS scene layer from a URL.
ShowCalloutShow a callout with the latitude and longitude of user-tapped points.
SurfacePlacementsPosition graphics relative to a surface using different surface placement modes.
TerrainExaggerationVertically exaggerate terrain in a scene.
WMTSLayerDisplay a layer from a Web Map Tile Service.