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

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns=""
      <RowDefinition Height="auto" />
      <RowDefinition Height="*" />
      <Button x:Name="MapsButton" Text="Maps" Clicked="OnMapsClicked"></Button>
      <esriUI:MapView x:Name="MyMapView" Grid.Row="1"/>
// 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 Xamarin.Forms;

namespace ArcGISRuntime.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 : ContentPage
        // String array to hold urls to publicly available web maps
        private string[] itemURLs = {

        // String array to store titles for the webmaps specified above. These titles are in the same order as the urls above
        private string[] titles = {
            "Kilauea volcanic eruption",
            "USA Tapestry Segmentation",
            "Geology of United States"

        public OpenMapURL()
            InitializeComponent ();

            // Create the UI, setup the control references and execute initialization 

        private void Initialize()
            // Create a new Map instance with url of the webmap that is displayed by default
            Map myMap = new Map(new Uri(itemURLs[0]));

            // Provide used Map to the MapView
            MyMapView.Map = myMap;

        private async void OnMapsClicked(object sender, EventArgs e)
            // Show sheet and get title from the selection
            string selectedMapTitle = 
                await ((Page)Parent).DisplayActionSheet("Select map", "Cancel",null, titles);

            // If selected cancel do nothing
            if (selectedMapTitle == null || selectedMapTitle == "Cancel") return;

            // Get index that is used to get the selected url
            int selectedIndex = titles.ToList().IndexOf(selectedMapTitle);

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