summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2017-01-08 12:53:23 -0800
committerGitHub <noreply@github.com>2017-01-08 12:53:23 -0800
commit901c806916deb30affa7a8a2884069cd28dba4ca (patch)
tree38f0d0774f7fde3cd8a59aa97881ee971126ca47
parentd3a2ffe747550216b19d678c40980231baeeef11 (diff)
downloadqtlocation-mapboxgl-901c806916deb30affa7a8a2884069cd28dba4ca.tar.gz
[ios] Only use non nil presentationLayers to adjust annotation views (#7626)
Views that are added outside of the viewport do not always have an instantiated presentationLayer. Attempting to use a nil presentationLayer to move a view offscreen resulted in the view being pinned to the left side of the view port (at x == 0).
-rw-r--r--platform/ios/src/MGLMapView.mm7
1 files changed, 6 insertions, 1 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index b01ab09fb4..6b59ad8465 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -4797,7 +4797,12 @@ public:
else
{
CGRect adjustedFrame = annotationView.frame;
- adjustedFrame.origin.x = CGRectGetWidth(annotationView.layer.presentationLayer.frame) * -2.0;
+ 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;
+ }
annotationView.frame = adjustedFrame;
[self enqueueAnnotationViewForAnnotationContext:annotationContext];
}