summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wray <jason@mapbox.com>2016-04-25 16:19:47 -0400
committerJason Wray <jason@mapbox.com>2016-04-25 17:00:43 -0400
commit8ce0fb4739f68cd3d5b65b0ded0346053855fa3f (patch)
tree77b060839cc71a4398090e14cd444a55ca774de1
parent0339639e3d7ac9dafda22a7f44d3d03780cf1470 (diff)
downloadqtlocation-mapboxgl-8ce0fb4739f68cd3d5b65b0ded0346053855fa3f.tar.gz
[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
-rw-r--r--platform/ios/src/MGLUserLocationAnnotationView.m20
1 files changed, 20 insertions, 0 deletions
diff --git a/platform/ios/src/MGLUserLocationAnnotationView.m b/platform/ios/src/MGLUserLocationAnnotationView.m
index 98b0c87bd2..72045f05e6 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;