View inWPFWinUIUWPFormsiOSAndroidView on GitHub
Display the map at an initial viewpoint representing a bounding geometry.
Use case
Setting the initial viewpoint is useful when a user wishes to first load the map at a particular area of interest.
How to use the sample
When the sample loads, note that the map view opens at the initial viewpoint defined on the map.
How it works
- Instantiate a
Map
object.
- Instantiate a
Viewpoint
object using an Envelope
object.
- Set the starting location of the map with
map.InitialViewpoint
.
- Set the map in the
MapView
.
Relevant API
- Envelope
- Map
- MapView
- Point
- Viewpoint
extent, envelope, initial, viewpoint, zoom
Sample Code
SetInitialMapArea.xamlSetInitialMapArea.xamlSetInitialMapArea.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
<UserControl
x:Class="ArcGISRuntime.WinUI.Samples.SetInitialMapArea.SetInitialMapArea"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<esriUI:MapView x:Name="MyMapView"/>
</Grid>
</UserControl>