[ios] Do not deselect annotations any longer when map is zoomed/panned or annotation is moved out of the visible bounds

This commit is contained in:
Benedikt Huss
2017-02-10 20:45:08 +01:00
committed by Minh Nguyễn
parent e6c15d0f6f
commit b9be66f287
2 changed files with 7 additions and 21 deletions

View File

@@ -41,6 +41,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* Fixed flickering that occurred when panning past the antimeridian. ([#7574](https://github.com/mapbox/mapbox-gl-native/pull/7574))
* Added a `MGLDistanceFormatter` class for formatting geographic distances. ([#7888](https://github.com/mapbox/mapbox-gl-native/pull/7888))
* Added a method to MGLMapViewDelegate, `-mapView:shouldChangeFromCamera:toCamera:`, that you can implement to restrict which parts the user can navigate to using gestures. ([#5584](https://github.com/mapbox/mapbox-gl-native/pull/5584))
* Annotations are no longer deselected when the map is panned or zoomed, even if the annotation moves out of the visible bounds. ([#8022](https://github.com/mapbox/mapbox-gl-native/pull/8022))
## 3.4.1 - January 25, 2017

View File

@@ -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:)])