summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenedikt Huss <ben305@users.noreply.github.com>2017-02-10 20:45:08 +0100
committerMinh Nguyễn <mxn@1ec5.org>2017-02-11 13:34:33 -0800
commitb9be66f287ade7275ecc18f21a456998e4163318 (patch)
tree700e76ce2f0edd2434db6d3048a097a9a7fdcbe8
parente6c15d0f6f285bc604c0d93381b9b1d3957cb5c9 (diff)
downloadqtlocation-mapboxgl-b9be66f287ade7275ecc18f21a456998e4163318.tar.gz
[ios] Do not deselect annotations any longer when map is zoomed/panned or annotation is moved out of the visible bounds
-rw-r--r--platform/ios/CHANGELOG.md1
-rw-r--r--platform/ios/src/MGLMapView.mm27
2 files changed, 7 insertions, 21 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index 87b2b8c05f..c81ae31e2c 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -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
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:)])