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

Improve user location annotation performance #6019

Merged
merged 3 commits into from
Aug 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion platform/ios/src/MGLFaux3DUserLocationAnnotationView.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ - (void)drawPuck
_puckDot.backgroundColor = [[UIColor whiteColor] CGColor];
_puckDot.shadowColor = [[UIColor blackColor] CGColor];
_puckDot.shadowOpacity = 0.25;
_puckDot.shadowPath = [[UIBezierPath bezierPathWithOvalInRect:_puckDot.bounds] CGPath];

if (self.mapView.camera.pitch)
{
Expand Down Expand Up @@ -291,13 +292,22 @@ - (void)drawDot
if (accuracyRingSize > MGLUserLocationAnnotationDotSize + 15)
{
_accuracyRingLayer.hidden = NO;

// disable implicit animation of the accuracy ring, unless triggered by a change in accuracy
id shouldDisableActions = (_oldHorizontalAccuracy == self.userLocation.location.horizontalAccuracy) ? (id)kCFBooleanTrue : (id)kCFBooleanFalse;

[CATransaction begin];
[CATransaction setValue:shouldDisableActions forKey:kCATransactionDisableActions];

_accuracyRingLayer.bounds = CGRectMake(0, 0, accuracyRingSize, accuracyRingSize);
_accuracyRingLayer.cornerRadius = accuracyRingSize / 2;

// match the halo to the accuracy ring
_haloLayer.bounds = _accuracyRingLayer.bounds;
_haloLayer.cornerRadius = _accuracyRingLayer.cornerRadius;
_haloLayer.shouldRasterize = NO;

[CATransaction commit];
}
else
{
Expand Down Expand Up @@ -365,6 +375,7 @@ - (void)drawDot
_dotBorderLayer.backgroundColor = [[UIColor whiteColor] CGColor];
_dotBorderLayer.shadowColor = [[UIColor blackColor] CGColor];
_dotBorderLayer.shadowOpacity = 0.25;
_dotBorderLayer.shadowPath = [[UIBezierPath bezierPathWithOvalInRect:_dotBorderLayer.bounds] CGPath];

if (self.mapView.camera.pitch)
{
Expand All @@ -385,7 +396,6 @@ - (void)drawDot
{
_dotLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize * 0.75];
_dotLayer.backgroundColor = [self.mapView.tintColor CGColor];
_dotLayer.shouldRasterize = NO;

// set defaults for the animations
CAAnimationGroup *animationGroup = [self loopingAnimationGroupWithDuration:1.5];
Expand Down