Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] Only use non nil presentationLayers to adjust annotation views (#…
Browse files Browse the repository at this point in the history
…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).
  • Loading branch information
boundsj authored Jan 8, 2017
1 parent d3a2ffe commit 901c806
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4797,7 +4797,12 @@ - (void)updateAnnotationViews
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];
}
Expand Down

0 comments on commit 901c806

Please sign in to comment.