Display device location

View inWPFUWPFormsiOSAndroid
View on GitHub
Sample viewer app

Display your current position on the map, as well as switch between different types of auto pan Modes.

Image of display device location

Use case

When using a map within a GIS, it may be helpful for a user to know their own location within a map, whether that's to aid the user's navigation or to provide an easy means of identifying/collecting geospatial information at their location.

How to use the sample

Select an autopan mode, then use the buttons to start and stop location display.

How it works

  1. Create a MapView.
  2. Get the LocationDisplay object by calling getLocationDisplay() on the map view.
  3. Use start() and stop() on the LocationDisplay object as necessary.

Relevant API

  • LocationDisplay
  • LocationDisplay.AutoPanMode
  • Map
  • MapView

Additional information

Location permissions are required for this sample.

Tags

compass, GPS, location, map, mobile, navigation

Sample Code

DisplayDeviceLocation.xamlDisplayDeviceLocation.xaml.cs
                                      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<UserControl x:Class="ArcGISRuntime.WPF.Samples.DisplayDeviceLocation.DisplayDeviceLocation"
             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:esri="http://schemas.esri.com/arcgis/runtime/2013"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <TextBlock Text="Select autopan mode."
                           Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"
                           TextWrapping="Wrap" TextAlignment="Center" FontWeight="Bold"
                           Margin="0,0,0,5" />
                <ComboBox x:Name="ModeChooser"
                          Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
                          SelectionChanged="OnModeChooserSelectionChanged" />
                <Button Content="Start"
                        Margin="0,5,5,0" Grid.Row="2" Grid.Column="0"
                        Click="OnStartButtonClicked" />
                <Button Content="Stop"
                        Margin="5,5,0,0" Grid.Row="2" Grid.Column="1"
                        Click="OnStopButtonClicked" />
            </Grid>
        </Border>
    </Grid>
</UserControl>

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