Manage annotation events in your MAUI app

In addition to controlling annotation changes via our create, update, and delete APIs, we also expose a number of events that can be used to intercept annotation changes that originate in the user interface (UI) by clicks from the user.

EventUse case
IAnnotation.FocusedFires when an annotation is focused.
IAnnotation.UnfocusedFires when an annotation loses focus.
IAnnotation.PressedFires when an annotation is pressed.
IAnnotation.SelectedFires when an annotation is selected.
IAnnotation.DeselectedFires when an annotation is deselected.
IAnnotationManager.AnnotationsChangedFires when annotations change either due to user action or via the API.
IAnnotationManager.AnnotationsChangingFires when a user starts or ends an interaction with an annotation.
IAnnotationManager.AnnotationsCreatedFires when a new annotation is created.
IAnnotationManager.AnnotationsDeletedFires when annotations were deleted.
IAnnotationManager.AnnotationsLoadedFires when annotations are loaded from annotation provider.
IAnnotationManager.AnnotationsSavingFires before annotations will be saved.
IAnnotationManager.AnnotationsSavedFires before annotations were saved.
IAnnotationManager.AnnotationsUpdatedFires when annotations were updated.
annotation.Focused += () => {
Console.WriteLine("Annotation focused");
};
annotation.Unfocused += () => {
Console.WriteLine("Annotation unfocused");
};
annotation.Pressed += (isSelected, preventDefault) => {
Console.WriteLine("Annotation pressed");
};
annotation.Selected += () => {
Console.WriteLine("Annotation selected");
};
annotation.Deselected += () => {
Console.WriteLine("Annotation deselected");
};
annotationManager.AnnotationsChanged += () => {
Console.WriteLine("Annotations changed");
};
annotationManager.AnnotationsChanging += (annotations, reason) => {
if (reason.AnnotationsChaningReason.DrawEnd) {
Console.WriteLine("Annotations changing");
}
};
annotationManager.AnnotationsCreated += (annotations) => {
foreach(var annotation in annotations) {
Console.WriteLine(annotation.id);
}
};
annotationManager.AnnotationsDeleted += (annotations) => {
foreach(var annotation in annotations) {
Console.WriteLine(annotation.id);
}
};
annotationManager.AnnotationsLoaded += (annotations) => {
foreach(var annotation in annotations) {
Console.WriteLine(annotation.id);
}
};
annotationManager.AnnotationsSaving += () => {
Console.WriteLine("Saving annotations");
};
annotationManager.AnnotationsSaved += () => {
Console.WriteLine("Saved annotations");
};
annotationManager.AnnotationsUpdated += (annotations) => {
foreach(var annotation in annotations) {
Console.WriteLine(annotation.id);
}
};