diff options
Diffstat (limited to 'platform/ios/src/MGLMapView.mm')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index cc86ed1e53..77fd810e16 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3259,6 +3259,11 @@ public: if (annotationView) { + // Make sure that the annotation views are selected/deselected correctly because + // annotations are not dismissed when they move out of the visible bounds + BOOL isViewForSelectedAnnotation = self.selectedAnnotation == annotation; + [annotationView setSelected:isViewForSelectedAnnotation]; + annotationView.annotation = annotation; annotationView.mapView = self; CGRect bounds = UIEdgeInsetsInsetRect({ CGPointZero, annotationView.frame.size }, annotationView.alignmentRectInsets); @@ -4710,30 +4715,10 @@ public: && 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)]) + if (dismissesAutomatically || (calloutView && ![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]; - } - } - } } if ( ! [self isSuppressingChangeDelimiters] && [self.delegate respondsToSelector:@selector(mapView:regionWillChangeAnimated:)]) |