summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2017-05-09 12:08:41 -0700
committerJesse Bounds <jesse@rebounds.net>2017-05-09 13:09:19 -0700
commitc6c7c2cd743bae543f4041b999ec32fc076ea76a (patch)
tree2abdbe9c45f69add7fadd92ad49cc2a437b0764c
parent25c19902a22e240da4e7ebf1974125b7e67bd21e (diff)
downloadqtlocation-mapboxgl-c6c7c2cd743bae543f4041b999ec32fc076ea76a.tar.gz
[ios] Use map view frame to calculate annotation view reuse adjustments (#8926)
* [ios] Use map view frame to calculate annotation view reuse adjustments The value for determining the visible viewport buffer and also the distance to move offscreen an annotation view outside of that buffer was based on the annotation view width and height. This changes that to use the map viewport width and height as constants and avoids a class of bugs where the annotation view would become detached from the tracking system when it did not have a size or was animating from a small to large size.
-rw-r--r--platform/ios/src/MGLMapView.mm14
1 files changed, 6 insertions, 8 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 4b5ca8679a..51b65f11b1 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -4935,8 +4935,10 @@ public:
// If the map is pitched consider the viewport to be exactly the same as the bounds.
// Otherwise, add a small buffer.
- CGFloat widthAdjustment = self.camera.pitch > 0.0 ? 0.0 : -_largestAnnotationViewSize.width * 2.0;
- CGFloat heightAdjustment = self.camera.pitch > 0.0 ? 0.0 : -_largestAnnotationViewSize.height * 2.0;
+ CGFloat largestWidth = MAX(_largestAnnotationViewSize.width, CGRectGetWidth(self.frame));
+ CGFloat largestHeight = MAX(_largestAnnotationViewSize.height, CGRectGetHeight(self.frame));
+ CGFloat widthAdjustment = self.camera.pitch > 0.0 ? 0.0 : -largestWidth * 2.0;
+ CGFloat heightAdjustment = self.camera.pitch > 0.0 ? 0.0 : -largestHeight * 2.0;
CGRect viewPort = CGRectInset(self.bounds, widthAdjustment, heightAdjustment);
NSArray *visibleAnnotations = [self visibleAnnotationsInRect:viewPort];
@@ -5012,13 +5014,9 @@ public:
}
else
{
+ // Move the annotation view far out of view to the left
CGRect adjustedFrame = annotationView.frame;
- if (annotationView.layer.presentationLayer) {
- adjustedFrame.origin.x = -CGRectGetWidth(annotationView.layer.presentationLayer.frame) * 10.0;
- } else {
- // views that are added off screen do not have a presentationLayer
- adjustedFrame.origin.x = -CGRectGetWidth(adjustedFrame) * 10.0;
- }
+ adjustedFrame.origin.x = -CGRectGetWidth(self.frame) * 10.0;
annotationView.frame = adjustedFrame;
[self enqueueAnnotationViewForAnnotationContext:annotationContext];
}