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.WPF.Samples.ManageBookmarks.ManageBookmarks"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
<Grid>
<esri:MapView x:Name="MyMapView" />
<Border Style="{StaticResource BorderStyle}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="180" />
<ColumnDefinition Width="*" />
</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."
TextAlignment="Center" />
<TextBlock Grid.Row="1"
Grid.Column="0"
Margin="5"
VerticalAlignment="Center"
Text="Bookmarks:" />
<ComboBox x:Name="BookmarkChooser"
Grid.Row="1"
Grid.Column="1"
Width="160"
Margin="5"
DisplayMemberPath="Name"
SelectionChanged="OnBookmarkChooserSelectionChanged" />
<Button x:Name="ButtonAddBookmark"
Grid.Row="1"
Grid.Column="2"
Margin="5"
Padding="5,0,5,0"
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"
Text="Bookmark Name:"
TextWrapping="Wrap" />
<TextBox x:Name="TextBoxBookmarkName"
Grid.Row="0"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="5" />
<Button x:Name="ButtonAddDone"
Grid.Row="1"
Grid.Column="1"
Margin="5"
Click="ButtonAddDone_Click"
Content="OK" />
<Button x:Name="ButtonCancel"
Grid.Row="1"
Grid.Column="2"
Margin="5"
Click="ButtonCancel_Click"
Content="Cancel" />
</Grid>
</Grid>
</Border>
</Grid>
</UserControl>