summaryrefslogtreecommitdiff
path: root/platform/ios/src/MGLMapView.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/ios/src/MGLMapView.mm')
-rw-r--r--platform/ios/src/MGLMapView.mm50
1 files changed, 34 insertions, 16 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index f8ca673093..c85746d1b5 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -4561,21 +4561,34 @@ public:
|| self.userTrackingMode == MGLUserTrackingModeNone
|| self.userTrackingState != MGLUserTrackingStateChanged)
{
- // Deselect annotation if it lies outside the viewport
- if (self.selectedAnnotation) {
- MGLAnnotationTag tag = [self annotationTagForAnnotation:self.selectedAnnotation];
- MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(tag);
- MGLAnnotationView *annotationView = annotationContext.annotationView;
-
- CGRect rect = [self positioningRectForCalloutForAnnotationWithTag:tag];
-
- if (annotationView)
- {
- rect = annotationView.frame;
- }
-
- if ( ! CGRectIntersectsRect(rect, self.frame)) {
- [self deselectAnnotation:self.selectedAnnotation animated:NO];
+ UIView<MGLCalloutView> *calloutView = self.calloutViewForSelectedAnnotation;
+ BOOL dismissesAutomatically = (calloutView
+ && [calloutView respondsToSelector:@selector(dismissesAutomatically)]
+ && calloutView.dismissesAutomatically);
+ // dismissesAutomatically is an optional property and we want to dismiss
+ // the callout view if it's unimplemented.
+ if (dismissesAutomatically || ![calloutView respondsToSelector:@selector(dismissesAutomatically)])
+ {
+ [self deselectAnnotation:self.selectedAnnotation animated:NO];
+ }
+ else
+ {
+ // Deselect annotation if it lies outside the viewport
+ if (self.selectedAnnotation) {
+ MGLAnnotationTag tag = [self annotationTagForAnnotation:self.selectedAnnotation];
+ MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(tag);
+ MGLAnnotationView *annotationView = annotationContext.annotationView;
+
+ CGRect rect = [self positioningRectForCalloutForAnnotationWithTag:tag];
+
+ if (annotationView)
+ {
+ rect = annotationView.frame;
+ }
+
+ if ( ! CGRectIntersectsRect(rect, self.frame)) {
+ [self deselectAnnotation:self.selectedAnnotation animated:NO];
+ }
}
}
}
@@ -4816,7 +4829,12 @@ public:
UIView <MGLCalloutView> *calloutView = self.calloutViewForSelectedAnnotation;
id <MGLAnnotation> annotation = calloutView.representedObject;
- if (calloutView && annotation)
+ BOOL isAnchoredToAnnotation = (calloutView
+ && annotation
+ && [calloutView respondsToSelector:@selector(isAnchoredToAnnotation)]
+ && calloutView.isAnchoredToAnnotation);
+
+ if (isAnchoredToAnnotation)
{
MGLAnnotationTag tag = [self annotationTagForAnnotation:annotation];
MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(tag);