Manage bookmarks

View inMAUIUWPWPFWinUIView on GitHub

Access and create bookmarks on a map.

Image of manage bookmarks

Use case

Bookmarks are used for easily storing and accessing saved locations on the map. Bookmarks are of interest in educational apps (e.g. touring historical sites) or more specifically, for a land management company wishing to visually monitor flood levels over time at a particular location. These locations can be saved as bookmarks and revisited easily each time their basemap data has been updated (e.g. working with up to date satellite imagery to monitor water levels).

How to use the sample

The map in the sample comes pre-populated with a set of bookmarks. To access a bookmark and move to that location, click on a bookmark's name from the list. To add a bookmark, pan and/or zoom to a new location and click on the 'Add Bookmark' button. Enter a unique name for the bookmark and click ok, and the bookmark will be added to the list

How it works

  1. Instantiate a new Map object and create a BookmarkList with map.Bookmarks.
  2. To create a new bookmark and add it to the bookmark list:
    • Instantiate a new Bookmark object passing in text (the name of the bookmark) and a Viewpoint as parameters.
    • Add the new bookmark to the book mark list with BookmarkList.Add(bookmark).

Relevant API

  • Bookmark
  • BookmarkList
  • Viewpoint

Tags

bookmark, extent, location, zoom

Sample Code

ManageBookmarks.xamlManageBookmarks.xamlManageBookmarks.xaml.cs
Use dark colors for code blocksCopy
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<UserControl
    x:Class="ArcGIS.UWP.Samples.ManageBookmarks.ManageBookmarks"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
    <Grid>
        <esriUI:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}"
                Width="425">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <TextBlock Text="Tap 'Add' to create a new bookmark for the current extent."
                           Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3"
                           Margin="5"
                           TextWrapping="Wrap" FontWeight="SemiBold" />
                <TextBlock Text="Bookmarks:"
                           Grid.Row="1" Grid.Column="0"
                           VerticalAlignment="Center" FontWeight="SemiBold"
                           Margin="5" />
                <ComboBox x:Name="BookmarkChooser"
                          Grid.Row="1" Grid.Column="1"
                          DisplayMemberPath="Name"
                          HorizontalAlignment="Stretch"
                          Margin="5,0,5,0"
                          SelectionChanged="OnBookmarkChooserSelectionChanged" />
                <Button x:Name="ButtonAddBookmark"
                        Grid.Row="1" Grid.Column="2"
                        Content="Add" HorizontalAlignment="Stretch"
                        Click="ButtonAddBookmark_Click" />
                <Grid x:Name="BorderAddBookmark"
                      Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3"
                      Visibility="Collapsed">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Bookmark Name:"
                               Margin="5"
                               FontWeight="SemiBold" VerticalAlignment="Center"
                               Grid.Row="0" Grid.Column="0" />
                    <TextBox x:Name="TextBoxBookmarkName"
                             Margin="5"
                             Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" />
                    <Button Content="OK"
                            Grid.Row="1" Grid.Column="1"
                            Margin="5,0,2.5,0"
                            HorizontalAlignment="Stretch"
                            Click="ButtonAddDone_Click" />
                    <Button Content="Cancel"
                            Grid.Row="1" Grid.Column="2"
                            Margin="2.5,0,5,0"
                            HorizontalAlignment="Stretch"
                            Click="ButtonCancel_Click" />
                </Grid>
            </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.