Represents a geographic location in the map. This location can also contain a specific point in time.
Zoom To Bookmark by name
public Task<bool> ZoomToBookmark(string bookmarkName)
{
return QueuedTask.Run(() =>
{
//Get the active map view.
var mapView = MapView.Active;
if (mapView == null)
return false;
//Get the first bookmark with the given name.
var bookmark = mapView.Map.GetBookmarks().FirstOrDefault(b => b.Name == bookmarkName);
if (bookmark == null)
return false;
//Zoom the view to the bookmark.
return mapView.ZoomTo(bookmark);
});
}
public async Task<bool> ZoomToBookmarkAsync(string bookmarkName)
{
//Get the active map view.
var mapView = MapView.Active;
if (mapView == null)
return false;
//Get the first bookmark with the given name.
var bookmark = await QueuedTask.Run(() => mapView.Map.GetBookmarks().FirstOrDefault(b => b.Name == bookmarkName));
if (bookmark == null)
return false;
//Zoom the view to the bookmark.
return await mapView.ZoomToAsync(bookmark, TimeSpan.FromSeconds(2));
}
Create a new bookmark using the active map view
public Task<Bookmark> AddBookmarkAsync(string name)
{
return QueuedTask.Run(() =>
{
//Get the active map view.
var mapView = MapView.Active;
if (mapView == null)
return null;
//Adding a new bookmark using the active view.
return mapView.Map.AddBookmark(mapView, name);
});
}
Get the collection of bookmarks for the project
public Task<ReadOnlyObservableCollection<Bookmark>> GetProjectBookmarksAsync()
{
//Get the collection of bookmarks for the project.
return QueuedTask.Run(() => Project.Current.GetBookmarks());
}
Get Map Bookmarks
public Task<ReadOnlyObservableCollection<Bookmark>> GetActiveMapBookmarksAsync()
{
return QueuedTask.Run(() =>
{
//Get the active map view.
var mapView = MapView.Active;
if (mapView == null)
return null;
//Return the collection of bookmarks for the map.
return mapView.Map.GetBookmarks();
});
}
Remove bookmark with a given name
public Task RemoveBookmarkAsync(Map map, string name)
{
return QueuedTask.Run(() =>
{
//Find the first bookmark with the name
var bookmark = map.GetBookmarks().FirstOrDefault(b => b.Name == name);
if (bookmark == null)
return;
//Remove the bookmark
map.RemoveBookmark(bookmark);
});
}
Change the thumbnail for a bookmark
public Task SetThumbnailAsync(Bookmark bookmark, string imagePath)
{
//Set the thumbnail to an image on disk, ie. C:\Pictures\MyPicture.png.
BitmapImage image = new BitmapImage(new Uri(imagePath, UriKind.RelativeOrAbsolute));
return QueuedTask.Run(() => bookmark.SetThumbnail(image));
}
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3.0 or higher.