View in MAUI WPF WinUI UWP View 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 and Recent Hurricanes, Cyclones and Typhoons.

Tags

portal item, web map

Sample Code

OpenMapURL.xaml OpenMapURL.xaml OpenMapURL.xaml.cs
<UserControl x:Class="ArcGIS.WPF.Samples.OpenMapURL.OpenMapURL"
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 FontWeight="Bold"
Text="Select a map."
TextAlignment="Center"
TextWrapping="Wrap" />
<ComboBox x:Name="MapsChooser"
Margin="0,5,0,0"
SelectionChanged="MapSelectionChanged" />
</StackPanel>
</Border>
</Grid>
</UserControl>