Open map URL

View inAndroidFormsUWPWPFWinUIiOSView on GitHub

Display a web map.

Image of open map URL

Use case

For displaying web maps stored on ArcGIS Online.

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 http://www.arcgis.com.
  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

About the data

The web maps accessed by this sample show Geology for United States, Terrestrial Ecosystems of the World and Recent Hurricanes, Cyclones and Typhoons.

Tags

portal item, web map

Sample Code

OpenMapURL.xamlOpenMapURL.xamlOpenMapURL.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGISRuntime.Samples.OpenMapURL.OpenMapURL"
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Button x:Name="MapsButton"
                Clicked="OnMapsClicked"
                Text="Maps" />
        <esriUI:MapView x:Name="MyMapView" Grid.Row="1" />
    </Grid>
</ContentPage>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.