Click or drag to resize
MapViewMap Property
The current Map content displayed in the MapView

Namespace: Esri.ArcGISRuntime.Controls
Assembly: Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 10.2.7.0 (10.2.7.1234)
Syntax
public Map Map { get; set; }

Property Value

Type: Map
Remarks

The MapView is a container that holds a Map. A Map holds a collection of layers. Layers are visual representations of geographic information and come in many forms. The types of layers that are displayed in a MapView are two dimensional in nature; meaning they are displayed in X/Y (a.k.a. Latitude/Longitude) coordinate space.

There is only one Map per MapView and it is set by the MapView.Map Property. Multiple Map objects can be created and swapped out dynamically as the application is running in the MapView.

To set the SpatialReference of the MapView, a Map must be added to the MapView.Map Property and either: (1) the Map.InitialViewpoint must be set (including the Envelope's Extent and SpatialReference) or (2) at least one layer (which has SpatialReference information) must be added to the Map's LayerCollection (typically via the Map.Layers.Add() Method).

Examples

Demonstrates switching out different Map objects (with different layers) for the MapView.Map Property.

Code example using the MapView.Map Property to swap out multiple Map objects..

XAML
<Window x:Class="MultipleMapsInMapView.MainWindow"
        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" 
        Title="MainWindow" Height="600" Width="800">

    <Grid>
        <StackPanel Orientation="Vertical">
            <StackPanel Orientation="Horizontal">

                <!-- Add a MapView Control.  We will set various Map's (with different Layers) in code behind based 
                on the users ListBox choice.  -->
                <esri:MapView x:Name="MyMapView" Width="637" Height="568" VerticalAlignment="Top"/>

                <TextBlock Width="10"/>
                <StackPanel Orientation="Vertical">
                    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Pick a Map" 
                               VerticalAlignment="Top" Height="20"/>

                    <!-- This is the ListBox that will have the various Map objects available. -->
                    <ListBox x:Name="ListBox1" VerticalAlignment="Top" Width="120" Height="300"
                             SelectionChanged="ListBox1_SelectionChanged_1"/>

                </StackPanel>
            </StackPanel>
        </StackPanel>
    </Grid>
</Window>

SPECIAL NOTE: The XAML displayed above comes from a C# project. If you are a VB.NET developer, you will need to modify the text for the x:Class namespace from "MultipleMapsInMapView.MainWindow" to be just "MainWindow".

// INSTRUCTIONS:
// Click on the various Map names in the ListBox to switch between different Map controls as the MapView.Map Property.
// Each Map Control will have a different collection of layers (some with different Spatial References).

namespace MultipleMapsInMapView
{

    public partial class MainWindow : System.Windows.Window
    {
        public MainWindow()
        {
            InitializeComponent();

            // Add three strings for the different Map objects that will be renderer.
            ListBox1.Items.Add("Map1");
            ListBox1.Items.Add("Map2");
            ListBox1.Items.Add("Map3");
        }

        private void ListBox1_SelectionChanged_1(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {

            if (ListBox1.SelectedItem.ToString() == "Map1")
            {

                // Create an ArcGISTiledMapServiceLayer and an ArcGISDynamicMapServiceLayer and add it to Map1. Then set the MyMapView.Map to Map1. 

                Esri.ArcGISRuntime.Controls.Map Map1 = new Esri.ArcGISRuntime.Controls.Map();

                Esri.ArcGISRuntime.Layers.ArcGISTiledMapServiceLayer ArcGISTiledMapServiceLayer1 = new Esri.ArcGISRuntime.Layers.ArcGISTiledMapServiceLayer();
                ArcGISTiledMapServiceLayer1.ServiceUri = "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer";
                ArcGISTiledMapServiceLayer1.ID = "World_Light_Gray_Base";

                Esri.ArcGISRuntime.Layers.ArcGISDynamicMapServiceLayer ArcGISDynamicMapServiceLayer1 = new Esri.ArcGISRuntime.Layers.ArcGISDynamicMapServiceLayer();
                ArcGISDynamicMapServiceLayer1.ServiceUri = "http://services.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_1990-2000_Population_Change/MapServer";
                ArcGISDynamicMapServiceLayer1.ID = "USA_1990-2000_Population_Change";

                Map1.Layers.Add(ArcGISTiledMapServiceLayer1);
                Map1.Layers.Add(ArcGISDynamicMapServiceLayer1);

                MyMapView.Map = Map1;

            }
            else if (ListBox1.SelectedItem.ToString() == "Map2")
            {

                // Create an ArcGISImageServiceLayer and add it to Map2. Then set the MyMapView.Map to Map2. 

                Esri.ArcGISRuntime.Controls.Map Map2 = new Esri.ArcGISRuntime.Controls.Map();

                Esri.ArcGISRuntime.Layers.ArcGISImageServiceLayer ArcGISImageServiceLayer2 = new Esri.ArcGISRuntime.Layers.ArcGISImageServiceLayer();
                ArcGISImageServiceLayer2.ServiceUri = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/CaliforniaDEM/ImageServer";
                ArcGISImageServiceLayer2.ID = "CaliforniaDEM";

                Map2.Layers.Add(ArcGISImageServiceLayer2);

                MyMapView.Map = Map2;

            }
            else if (ListBox1.SelectedItem.ToString() == "Map3")
            {

                // Create an ArcGISTiledMapServiceLayer and a FeatureLayer and add it to Map3. Then set the MyMapView.Map to Map3. 

                Esri.ArcGISRuntime.Controls.Map Map3 = new Esri.ArcGISRuntime.Controls.Map();
                Esri.ArcGISRuntime.Layers.ArcGISTiledMapServiceLayer ArcGISTiledMapServiceLayer3 = new Esri.ArcGISRuntime.Layers.ArcGISTiledMapServiceLayer();
                ArcGISTiledMapServiceLayer3.ServiceUri = "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer";
                ArcGISTiledMapServiceLayer3.ID = "World_Light_Gray_Base";

                Esri.ArcGISRuntime.Layers.FeatureLayer FeatureLayer3 = new Esri.ArcGISRuntime.Layers.FeatureLayer();
                Esri.ArcGISRuntime.Data.ServiceFeatureTable ServiceFeatureTable3 = new Esri.ArcGISRuntime.Data.ServiceFeatureTable();
                ServiceFeatureTable3.ServiceUri = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/0";
                ServiceFeatureTable3.OutFields = Esri.ArcGISRuntime.Tasks.Query.OutFields.All;
                FeatureLayer3.FeatureTable = ServiceFeatureTable3;

                Map3.Layers.Add(ArcGISTiledMapServiceLayer3);
                Map3.Layers.Add(FeatureLayer3);

                MyMapView.Map = Map3;

            }

        }

    }
}
See Also
Supported Platforms
This type is supported on the following ArcGIS Runtime .NET SDK platforms:
Windows Desktop
Windows Phone
Windows Store
Additional Examples
Hyperlink to ExampleDescription
AllLayersServiceInfo_FeatureServiceLayerInfoDemonstrates getting detailed ArcGIS Server MapServer metadata for various ArcGISDynamicMapServiceLayer and ArcGISTiledMapServiceLayer web services.
ArcGISDynamicMapServiceLayer_GetDetailsShows adding an ArcGISDynamicMapServiceLayer with a LayerDefinition applied (discovered by the ArcGISDynamicMapServiceLayer.GetDetailsAsync Method) and then modifying the LayerDefinition to change the features returned.
ArcGISDynamicMapServiceLayer_VisibleLayersShows obtaining which sub-layers are visible using the ArcGISDynamicMapServiceLayer.GetAllDetailsAsync Method. Then the user can interact with application and change the VisibleLayers of the ArcGISDynamicMapServiceLayer.
ArcGISDynamicMapServiceLayerImageFormatShows changing the return ImageFormat for ArcGISDynamicMapServiceLayer and how that appears visually in the Map.
ArcGISDynamicMapServiceLayerXamlAndCodeBehindShows creating an ArcGISDynamicMapServiceLayer in XAML and via code-behind. The ArcGISDynamicMapServiceLayer.InitializeAsync Method is used to obtain metadata about the layer (i.e. ID and Copyright) using the Async/Task framework.
ArcGISImageServiceLayerWindowShows creating an ArcGIS Image Service Layer and applying rendering rules.
ArcGISImageServiceLayerXamlAndCodeBehindShows adding an ArcGISImageServiceLayer via XAML and code-behind. The ArcGISImageServiceLayer.InitializeAsync Method is used to obtain metadata about the layer (i.e. ID and Description) using the Async/Task framework.
BaseMapsDemonstrates switching out various BaseMap (via ArcGISTiledMapServiceLayer) layers served up by ArcGIS Online.
CreateDynamicLayerInfosFromLayerInfosDemonstrates applying a custom rendering via XAML using the Dynamic Layer option of an ArcGISDynamicMapServiceLayer. Also, shows how to use the ArcGISDynamicMapServiceLayer.CreateDynamicLayerInfosFromLayerInfos Method to obtain the original rendering of the layer that was defined in the map service. The CreateDynamicLayerInfosFromLayerInfos is then used to reset the layer back to orignal rendering.
DynamicLayerInfoCollectionDemonstrates using various Renderers on a Dynamic Layer when the 'WorkspaceID' and 'DataSourceName' are known using a TableDataSource.
DynamicLayerInfosDemonstrates using various Renderers on a Dynamic Layer (via XAML and code-behind) when the 'WorkspaceID' and 'DataSourceName' are known using a TableDataSource.
Editor_SketchingDemonstrates sketching various geometric shapes on the map via the Editor.RequestShapeAsync method. The sketches are then added as Graphics in a GraphicsLayer and drawn on the map.
EditorConfigurationDemonstrates sketching Polyline shapes on the map via the Editor.RequestShapeAsync method. The sketches are then added as Graphics in a GraphicsLayer and drawn on the map. Multiple versions of customizing the symbology of the Editor are shown.
EqualGeometriesDemonstrates the differences in comparing a few polygon geometries to via the Geometry.IsEqual and GeometryEngine.Equals Methods.
FeatureLayer_IdentifyDemonstrates performing and Identify on a FeatureLayer. The FeatureLayer.HitTestAsync method is used to select (and highlight) the feature a user clicks/taps on as well as display specific attributes for that feature.
FeatureLayer_LabelingDemonstrates labeling highway names in a FeatureLayer.
FeatureLayer_SelectFeaturesByRectangleDemonstrates selecting features in a FeatureLayer by dragging a rectangle across the map. Features are then highlighted in the FeatureLayer and their selected ID values are displayed in a Listbox.
FeatureLayer_SetFeatureVisibleDemonstrates being able to turn off the visibility of a feature in a FeatureLayer by tapping on it.
FeatureLayerViaGeodatabaseDemonstrates creating a FeatureLayer from a GeodatabaseFeatureTable in an ArcGIS Runtime provisioned Geodatabase that is stored locally on disk.
FeatureLayerViaGeodatabaseWebDownloadDemonstrates downloading a Geodatabase on ArcGIS Server to the local disk and then creating a FeatureLayer from a GeodatabaseFeatureTable in the downloaded Geodatabase.
FeatureLayerViaShapefileDemonstrates creating a FeatureLayer from a ShapefileTable that is stored locally on disk.
FeatureLayerXamlAndCodeBehindShows creating a FeatureLayer in XAML and via code-behind. The FeatureLayer.InitializeAsync Method is used to obtain metadata about the layer (i.e. ID and Copyright) using the Async/Task framework.
FeatureServiceLayerInfo_CopyrightTextDemonstrates using the GetDetailsAsync Method to obtain the FeatureServiceLayerInfo.CopyrightText on an ArcGISDynamicMapServiceLayer.
FindTaskDemonstrates using the Query.FindTask operation to search for text in attribute fields of an ArcGIS Server map service and display the features found as graphics in a GraphicsLayer.
GeocodeFullAddressInputDemonstrates performing a geocode by submitting values for multiple address fields.
GeocodeSingleLineInputPerforms a single line geocode using either an online ArcGIS Locator service or a local Locator.
GeometryEngine_BufferDemonstrates using the powerful GeometryEngine local process to generate graphic buffer polygons based upon a user specified radius and mouse-clicks/taps on the map.
GeometryEngine_BufferWithUnionDemonstrates using the powerful GeometryEngine local process to generate a single graphic buffer (unioned) based upon multiple points provided by user interaction with the map.
GeometryEngine_ConvexHullDemonstrates using the powerful GeometryEngine local process to generate a convex hull graphic polygon based upon user specified mouse-clicks/taps on the map.
GeometryEngine_Difference_Intersection_UnionDemonstrates using the powerful GeometryEngine local process to perform the spatial analysis operations of Difference, Intersection, and Union on two input geometries.
GeometryEngine_TestingSpatialRelationshipsDemonstrates using the powerful GeometryEngine local process to test various spatial relationships (Contains, Crosses, Disjoint, Equals, Intersects, Overlaps, Touches, Within) between two input geometries.
GeoRSSLayerWindowCreates a GeoRssLayer based on the United States Geological Survey earthquake feed and assigned a SimpleRenderer.
GetAreaAllows the user to draw a polygon on the map and calculate the area via several methods.
GraphicsLayer_LabelingDemonstrates labeling city names where two AttributeLabelClass'es are used (one for smaller cities and one for larger ones).
GraphicsLayer_RenderingModeDemonstrates setting the various GraphicsLayer.RenderingMode options and their effect on TextSymbols when the MapView is rotated.
GraphicsLayerWindowDemonstrates various Graphics and GraphicsLayer related actions.
GraphicsOverlayDemonstrates using the Query.FindTask operation to return county features in an ArcGIS Server map service and display the features found as Graphics in a GraphicsOverlay. The user can perform a MapViewTapped on the Graphics to perform a GraphicsOverlay.HitTestAsync to select features and display attribute information.
IdentifyParameter_DynamicLayerInfosDemonstrates performing an Identify on a Dynamic Layer using the ESRI.ArcGISRuntime.Tasks.Query.IdentifyParameter.DynamicLayerInfos Property.
IdentifyTaskDemonstrates using the Query.IdentifyTask operation find a feature based upon it's geographic position in an ArcGIS Server map service and display it as a graphic in a GraphicsLayer.
InitialMapExtentCodeShows how to set the initial extent of the map (Map.InitialExtent) in code.
LayerCollectionDemonstrates the work-flow of creating a layer dynamically via code-behind. The process of a layer: (1) initializing, (2) determining when initialization is complete, and (3) error trapping for bad initialization is described in detail.
LayerDefinitionsDemonstrates setting numerous LayerDefinitions values on an ArcGISDynamicMapServiceLayer and visualizing the impact of the features being returned in the Map.
LayerDefinitionsSimpleDemonstrates setting the LayerDefinitions Property of an ArcGISDynamicMapServiceLayer where two sub-layers are present. One sub-layer has the LayerDefinition set in XAML and the other sub-layer has it's LayerDefinition set via code-behind.
LayerDrawingOptionCollectionDemonstrates using the existing rendering of a Dynamic Layer sub-layer of an ArcGISDynamicMapServiceLayer and switching to a custom rendering defined in code-behind for the Dynamic Layer.
LayerDrawingOptionsDemonstrates changing the rendering of the first sub-layer of an ArcGISDynamicMapServiceLayer using the Dynamic Layer capabilities of ArcGIS Server 10.1 and higher.
LayersInitializedDemonstrates implementing logic which is dependent on the layer collection being initialized.
MapServiceInfo_DocumentInfo_LayerServiceInfoDemonstrates getting detailed ArcGIS Server MapServer metadata to obtain MapServiceInfo data for various ArcGISDynamicMapServiceLayer and ArcGISTiledMapServiceLayer web services.
MapView_DragDropEventsDemonstrates creating a CsvLayer by performing a Drag-and-Drop from a file on the local disk in File Explorer to the MapView.
Mapview_LayerLoadedDemonstrates how to determine if a particular layer has loaded via the MapView.LayerLoaded Event.
MapView_LayersLoadedAsyncDemonstrates how to determine if a particular layer has loaded via the MapView.MapView_LayersLoadedAsync Method.
MapView_OverlaysDemonstrates displaying a UIElement on top of the MapView using the MapView.Overlays Property. This is useful for performing MapTip functionality.
MapView_SpatialReferenceDemonstrates reseting the MapView.SpatialReference by setting it to a new Map.
MultipleMapsInMapViewDemonstrates switching out different Map objects (with different layers) for the MapView.Map Property.
PictureFillSymbolDemonstrates the using a SimpleRenderer with options for PictureFillSymbol.
PictureMarkerSymbolDemonstrates the using a SimpleRenderer with options for SimpleMarkerSymbol, PictureMarkerSymbol, and TextMarkerSymbol.
PolygonBuilder_MakeIslandsShows how to use the PolygonBuilder to turn multiple independent Polygons into a single Polygon (use case: grouping island Polygons together into one record).
PolygonFromScratchDemonstrates creating a simple polygon, donut polygon, and multiple ring polygon via code-behind. An option to view coordinate information for each vertex in the polygons is provided.
ProximityResultDemonstrates identifying the nearest vertex and nearest coordinate in a polyline to a user clicked point in the map via ProximityResult.
QueryTableDataSourceDemonstrates adding a Dynamic Layer via code-behind using a QueryTableDataSource.
RoutingPointToPointDemonstrates simple point to point routing between two input locations.
RoutingWithBarriersShows routing and re-routing around user defined point, polyline, and polygon barriers.
RoutingWithDirectionsInteraction logic for RoutingWithDirections.xaml
SmoothGraphicAnimationAnimates a graphic smoothly between two user defined locations by calling the MapPoint.MoveTo method at regular intervals as defined by a DispatcherTimer. The distance the point is moved each time is calculated by a quintic easing function.