public ReadOnlyObservableCollection<Bookmark> GetBookmarks()
Public Function GetBookmarks() As ReadOnlyObservableCollection(Of Bookmark)
Return Value
The collection of bookmarks for the map.
public ReadOnlyObservableCollection<Bookmark> GetBookmarks()
Public Function GetBookmarks() As ReadOnlyObservableCollection(Of Bookmark)
| Exception | Description |
|---|---|
| ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
{
//Create a map frame and set its camera by zooming to the extent of an existing bookmark.
var project = Project.Current;
await QueuedTask.Run(() =>
{
//Build 2D envelope geometry
Coordinate2D mf_ll = new Coordinate2D(6.0, 8.5);
Coordinate2D mf_ur = new Coordinate2D(8.0, 10.5);
Envelope mf_env = EnvelopeBuilderEx.CreateEnvelope(mf_ll, mf_ur);
//Reference map, create MF and add to layout
MapProjectItem mapPrjItem = project.GetItems<MapProjectItem>()
.FirstOrDefault(item => item.Name.Equals("Map"));
Map mfMap = mapPrjItem.GetMap();
Bookmark bookmark = mfMap.GetBookmarks().FirstOrDefault(
b => b.Name == "Great Lakes");
MapFrame mfElm = ElementFactory.Instance.CreateMapFrameElement(
layout, mf_env, mfMap, "New Map Frame");
//Zoom to bookmark
mfElm.SetCamera(bookmark);
});
}
{
var greatLakes = map.GetLayersAsFlattenedList()
.OfType<FeatureLayer>().First(l => l.Name == "Great Lakes");
var michigan = map.GetBookmarks().First(b => b.Name == "Michigan");
//get all features - multiple feature geometries are always returned as a
//single multi-part
var all_features_outline = greatLakes.GetFeatureOutline(mapView, FeatureOutlineType.All);
//or get just the outline of selected features
var qry = new QueryFilter()
{
SubFields = "*",
WhereClause = "NAME in ('Huron','Michigan','Erie')"
};
greatLakes.Select(qry);
var sel_features_outline = greatLakes.GetFeatureOutline(
mapView, FeatureOutlineType.Selected);
greatLakes.ClearSelection();
//or just the visible features
mapView?.ZoomTo(michigan);
var visible_features_outline = greatLakes.GetFeatureOutline(
mapView, FeatureOutlineType.Visible);
}
{
await QueuedTask.Run(() =>
{
//Get the first bookmark with the given name.
var bookmark = mapView.Map.GetBookmarks().FirstOrDefault(b => b.Name == bookmarkName);
if (bookmark == null)
{
// Manage the error - bookmark not found
}
//Zoom the view to the bookmark.
mapView.ZoomTo(bookmark);
});
}
{
await QueuedTask.Run(() =>
{
//Get the first bookmark with the given name.
var bookmark = mapView.Map.GetBookmarks().FirstOrDefault(b => b.Name == bookmarkName);
if (bookmark == null)
{
// Manage the error - bookmark not found
}
//Zoom the view to the bookmark.
mapView.ZoomToAsync(bookmark, TimeSpan.FromSeconds(2));
});
}
{
await QueuedTask.Run(() =>
{
//Get the first bookmark with the given name.
var bookmark = mapView.Map.GetBookmarks().FirstOrDefault(b => b.Name == bookmarkName);
if (bookmark == null)
{
// Manage the error - bookmark not found
}
//Pan the view to the bookmark.
mapView.PanTo(bookmark);
});
}
{
//Get the first bookmark with the given name.
var bookmark = mapView.Map.GetBookmarks().FirstOrDefault(b => b.Name == bookmarkName);
if (bookmark == null)
{
// Manage the error - bookmark not found
}
//Pan the view to the bookmark.
mapView.PanToAsync(bookmark, TimeSpan.FromSeconds(2));
}
{
await QueuedTask.Run(() =>
{
//Return the collection of bookmarks for the map.
var result = mapView.Map.GetBookmarks();
// Use the bookmarks (if any)
});
}
{
await QueuedTask.Run(() =>
{
var map = mapView.Map;
//Find the first bookmark with the name
var bookmark = map.GetBookmarks().FirstOrDefault(b => b.Name == bookmarkName);
if (bookmark == null)
{
//Bookmark not found
}
//Move the bookmark to the top of the list
map.MoveBookmark(bookmark, 0);
});
}
{
oldBookmark = mapView.Map.GetBookmarks().FirstOrDefault(b => b.Name == bookmarkName);
oldBookmark.Rename(newBookmarkName);
}
{
await QueuedTask.Run(() =>
{
//Find the first bookmark with the name
var bookmark = mapView.Map.GetBookmarks().FirstOrDefault(b => b.Name == bookmarkName);
if (bookmark == null)
{
//Bookmark not found
}
//Remove the bookmark
mapView.Map.RemoveBookmark(bookmark);
});
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)