Set the map view to a new viewpoint.
Use case
Programatically navigate to a specified location in the map or scene. Use this to focus on a particular point or area of interest.
How to use the sample
The map view has several methods for setting its current viewpoint. Select a viewpoint from the UI to see the viewpoint changed using that method.
How it works
- Create a new
Map
object and set it to theMapView
object. - Change the map's
Viewpoint
using one of the available methods:
- Use
MapView.SetViewpointAsync()
to pan to a viewpoint. - Use
MapView.SetViewpointCenterAsync()
to center the viewpoint on aPoint
. - Use
MyMapView.SetViewpointScaleAsync()
to set a distance from the ground using a scale. - Use
MapView.SetViewpointGeometryAsync()
to set the viewpoint to a givenGeometry
.
Relevant API
- Geometry
- Map
- MapView
- Point
- Viewpoint
Additional information
Below are some other ways to set a viewpoint:
- SetViewpoint
- SetViewpointAsync
- SetViewpointCenterAsync
- SetViewpointGeometryAsync
- SetViewpointRotationAsync
- SetViewpointScaleAsync
Tags
animate, extent, pan, rotate, scale, view, zoom
Sample Code
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGISRuntime.Samples.ChangeViewpoint.ChangeViewpoint"
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="ViewpointsButton"
Clicked="OnViewpointsClicked"
Text="Viewpoints" />
<esriUI:MapView x:Name="MyMapView" Grid.Row="1" />
</Grid>
</ContentPage>