From 8ce0fb4739f68cd3d5b65b0ded0346053855fa3f Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Mon, 25 Apr 2016 16:19:47 -0400 Subject: [PATCH] [ios] Update frame size when changing dot/puck mode - Keeps the same center point - `updateFrameWithSize:` does not take CGSize because there is not yet support for non-square user location annotations --- .../ios/src/MGLUserLocationAnnotationView.m | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/platform/ios/src/MGLUserLocationAnnotationView.m b/platform/ios/src/MGLUserLocationAnnotationView.m index 98b0c87bd..72045f05e 100644 --- a/platform/ios/src/MGLUserLocationAnnotationView.m +++ b/platform/ios/src/MGLUserLocationAnnotationView.m @@ -181,6 +181,22 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck } } +- (void)updateFrameWithSize:(CGFloat)size +{ + CGSize newSize = CGSizeMake(size, size); + if (CGSizeEqualToSize(self.frame.size, newSize)) + { + return; + } + + // Update frame size, keeping the existing center point. + CGPoint oldCenter = self.center; + CGRect newFrame = self.frame; + newFrame.size = newSize; + [self setFrame:newFrame]; + [self setCenter:oldCenter]; +} + - (void)drawPuck { if ( ! _puckModeActivated) @@ -193,6 +209,8 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _haloLayer = nil; _dotBorderLayer = nil; _dotLayer = nil; + + [self updateFrameWithSize:MGLUserLocationAnnotationPuckSize]; } // background dot (white with black shadow) @@ -268,6 +286,8 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _puckDot = nil; _puckArrow = nil; + + [self updateFrameWithSize:MGLUserLocationAnnotationDotSize]; } BOOL showHeadingIndicator = _mapView.userTrackingMode == MGLUserTrackingModeFollowWithHeading;