summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wray <jason@mapbox.com>2018-05-21 21:51:11 -0400
committerJason Wray <jason@mapbox.com>2018-05-22 16:01:16 -0400
commiteba90df5bdfc73651273212b2478aff64f417955 (patch)
tree118c4a0b9a9bd586d8bb38d5717b7d994fa9add8
parent8a02fa42ecfb959a8958ccf414b5b8564c6d4d85 (diff)
downloadqtlocation-mapboxgl-eba90df5bdfc73651273212b2478aff64f417955.tar.gz
[ios] Use standard callout positioning for unanimated user location changes
Animated changes to the position of the user location annotation view still need to also handle updating its callout view, otherwise the two can become out of sync.
-rw-r--r--platform/ios/src/MGLMapView.mm32
1 files changed, 8 insertions, 24 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index e16411f2c5..7786d11a21 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -3582,7 +3582,7 @@ public:
return MGLAnnotationTagNotFound;
}
- return _annotationTagsByAnnotation.at(annotation);
+ return _annotationTagsByAnnotation.at(annotation);
}
- (void)addAnnotation:(id <MGLAnnotation>)annotation
@@ -5753,21 +5753,18 @@ public:
if (tag != MGLAnnotationTagNotFound) {
MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(tag);
annotationView = annotationContext.annotationView;
+ } else if (annotation == self.userLocation) {
+ annotationView = self.userLocationAnnotationView;
}
- CGRect rect = [self positioningRectForCalloutForAnnotationWithTag:tag];
+ CGRect positioningRect = annotationView ? annotationView.frame : [self positioningRectForCalloutForAnnotationWithTag:tag];
- if (annotationView)
- {
- rect = annotationView.frame;
- }
+ NSAssert( ! CGRectIsNull(positioningRect), @"Positioning rect should not be CGRectNull by this point");
- NSAssert(!CGRectIsNull(rect), @"Positioning rect should not be CGRectNull by this point");
+ CGPoint centerPoint = CGPointMake(CGRectGetMidX(positioningRect), CGRectGetMinY(positioningRect));
- CGPoint point = CGPointMake(CGRectGetMidX(rect), CGRectGetMinY(rect));
-
- if ( ! CGPointEqualToPoint(calloutView.center, point)) {
- calloutView.center = point;
+ if ( ! CGPointEqualToPoint(calloutView.center, centerPoint)) {
+ calloutView.center = centerPoint;
}
}
}
@@ -5840,19 +5837,6 @@ public:
annotationView.hidden = NO;
[annotationView update];
-
- if (_userLocationAnnotationIsSelected)
- {
- // Ensure the callout view still points to its annotation.
- UIView <MGLCalloutView> *calloutView = self.calloutViewForSelectedAnnotation;
- CGRect calloutFrame = calloutView.frame;
- calloutFrame.origin.x = annotationView.center.x - CGRectGetWidth(calloutFrame) / 2;
- calloutFrame.origin.y = CGRectGetMinY(annotationView.frame) - CGRectGetHeight(calloutFrame);
- if ( ! CGRectEqualToRect(calloutView.frame, calloutFrame))
- {
- calloutView.frame = calloutFrame;
- }
- }
}
else
{