Access and create bookmarks on a map.
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
- Instantiate a new
Map
object and create aBookmarkList
withmap.Bookmarks
. - 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 aViewpoint
as parameters. - Add the new bookmark to the book mark list with
BookmarkList.Add(bookmark)
.
- Instantiate a new
Relevant API
- Bookmark
- BookmarkList
- Viewpoint
Tags
bookmark, extent, location, zoom
Sample Code
<UserControl x:Class="ArcGISRuntime.WinUI.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 Width="425" Style="{StaticResource BorderStyle}">
<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 Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="3"
Margin="5"
FontWeight="SemiBold"
Text="Tap 'Add' to create a new bookmark for the current extent."
TextWrapping="Wrap" />
<TextBlock Grid.Row="1"
Grid.Column="0"
Margin="5"
VerticalAlignment="Center"
FontWeight="SemiBold"
Text="Bookmarks:" />
<ComboBox x:Name="BookmarkChooser"
Grid.Row="1"
Grid.Column="1"
Margin="5,0,5,0"
HorizontalAlignment="Stretch"
DisplayMemberPath="Name"
SelectionChanged="OnBookmarkChooserSelectionChanged" />
<Button x:Name="ButtonAddBookmark"
Grid.Row="1"
Grid.Column="2"
HorizontalAlignment="Stretch"
Click="ButtonAddBookmark_Click"
Content="Add" />
<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 Grid.Row="0"
Grid.Column="0"
Margin="5"
VerticalAlignment="Center"
FontWeight="SemiBold"
Text="Bookmark Name:" />
<TextBox x:Name="TextBoxBookmarkName"
Grid.Row="0"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="5" />
<Button Grid.Row="1"
Grid.Column="1"
Margin="5,0,2.5,0"
HorizontalAlignment="Stretch"
Click="ButtonAddDone_Click"
Content="OK" />
<Button Grid.Row="1"
Grid.Column="2"
Margin="2.5,0,5,0"
HorizontalAlignment="Stretch"
Click="ButtonCancel_Click"
Content="Cancel" />
</Grid>
</Grid>
</Border>
</Grid>
</UserControl>