Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for .NET

Open map URL

This code sample is available for these platforms:
View Sample on GitHub

Display a web map.

Image of open map URL

Use case

For displaying web maps stored on ArcGISOnline (e.g. soil survey results, as demonstrated in this sample).

How to use the sample

A web map can be selected from the drop-down list. On selection the web map displays in the map view.

How it works

  1. Create a Portal from the ArcGIS URL
  2. Create a PortalItem using the Portal and the web map ID: new PortalItem(portal, ID).
  3. Create a Map using the portal item.
  4. Set the map to the MapView.

Relevant API

  • Map
  • MapView
  • Portal
  • PortalItem

Additional information

Mobile map packages can also include address locators and geometric networks. For an example of this, see the "Mobile Map Search and Route Sample".


portal item, web map

Sample Code

        <esriUI:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
                <TextBlock Text="Select a map."
                           TextAlignment="Center" FontWeight="SemiBold" />
                <ComboBox x:Name="MapList" 
                          SelectionChanged="OnMapsChooseSelectionChanged" />
// Copyright 2016 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:
// 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;
using System.Linq;
using Windows.UI.Xaml.Controls;

namespace ArcGISRuntime.UWP.Samples.OpenMapURL
        name: "Open map URL",
        category: "Map",
        description: "Display a web map.",
        instructions: "A web map can be selected from the drop-down list. On selection the web map displays in the map view.",
        tags: new[] { "portal item", "web map" })]
    public partial class OpenMapURL
        // String array to hold URLs to publicly available web maps.
        private readonly string[] _itemUrls =

        // String array to store titles for the webmaps specified above. These titles are in the same order as the URLs above.
        private readonly string[] _titles =
            "Population Pressure",
            "USA Tapestry Segmentation",
            "Geology of United States"

        public OpenMapURL()

            // Select the first item.
            MapList.ItemsSource = _titles;
            MapList.SelectedIndex = 0;

        private void OnMapsChooseSelectionChanged(object sender, SelectionChangedEventArgs e)
            string selectedMapName = e.AddedItems[0].ToString();

            // Get index that is used to get the selected URL.
            int selectedIndex = _titles.ToList().IndexOf(selectedMapName);

            // Create a new Map instance with URL of the webmap that selected.
            MyMapView.Map = new Map(new Uri(_itemUrls[selectedIndex]));