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

Commit

Permalink
Reduce flickering somewhat, make code suuuuuper ugly
Browse files Browse the repository at this point in the history
  • Loading branch information
friedbunny committed Sep 7, 2015
1 parent 05fa3f1 commit f244254
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions platform/ios/MGLUserLocationAnnotationView.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ @implementation MGLUserLocationAnnotationView
CALayer *_dotBorderLayer;
CALayer *_dotLayer;
CALayer *_dotDomeLayer;
CALayer *_dotMaskDomeFrontLayer;

double _oldHeadingAccuracy;
CLLocationAccuracy _oldHorizontalAccuracy;
Expand Down Expand Up @@ -104,16 +105,19 @@ - (void)updatePitch

if (_dotDomeLayer)
{
CATransform3D t = CATransform3DRotate(CATransform3DIdentity, MGLRadiansFromDegrees(self.mapView.pitch * -1), 1.0, 0, 0);
/*CATransform3D t = CATransform3DRotate(CATransform3DIdentity, MGLRadiansFromDegrees(self.mapView.pitch * -1), 1.0, 0, 0);
_dotDomeLayer.transform = t;
CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale.xy"];
scaleAnimation.toValue = @0;
[_dotDomeLayer addAnimation:scaleAnimation forKey:@"domeScaleDown"];
[_dotDomeLayer addAnimation:scaleAnimation forKey:@"domeScaleDown"];*/

_dotDomeLayer.hidden = YES;
_dotDomeLayer.mask.hidden = YES;
_dotDomeLayer.speed = 0.0;

_dotLayer.mask = nil;
}

[self updateFaux3DEffect];
Expand All @@ -122,11 +126,20 @@ - (void)updatePitch
}
else if (_dotDomeLayer.hidden && (self.mapView.pitch == _oldPitch))
{
if ( ! self.mapView.pitch) return;

CATransform3D t = CATransform3DRotate(CATransform3DIdentity, MGLRadiansFromDegrees(-self.mapView.pitch), 1.0, 0, 0);
_dotDomeLayer.transform = t;

_dotDomeLayer.hidden = NO;
_dotDomeLayer.mask.hidden = NO;
_dotDomeLayer.speed = 1.0;

_dotLayer.mask = _dotMaskDomeFrontLayer;

CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale.xy"];
scaleAnimation.toValue = @1;
scaleAnimation.fillMode = kCAFillModeBackwards;

[_dotDomeLayer addAnimation:scaleAnimation forKey:@"domeScaleUp"];
}
Expand Down Expand Up @@ -393,12 +406,12 @@ - (void)drawDot
dotMaskDomeTopLayer.backgroundColor = [[UIColor blackColor] CGColor];
dotMaskDomeTopLayer.shouldRasterize = NO;

// CALayer *dotMaskDomeFrontLayer = [CALayer layer];
// dotMaskDomeFrontLayer.bounds = dotMaskDomeTopLayer.bounds;
// dotMaskDomeFrontLayer.position = CGPointMake(dotMaskDomeTopLayer.position.x, dotMaskDomeTopLayer.position.y + dotMaskDomeTopLayer.bounds.size.height);
// dotMaskDomeFrontLayer.backgroundColor = dotMaskDomeTopLayer.backgroundColor;
_dotMaskDomeFrontLayer = [CALayer layer];
_dotMaskDomeFrontLayer.bounds = dotMaskDomeTopLayer.bounds;
_dotMaskDomeFrontLayer.position = CGPointMake(dotMaskDomeTopLayer.position.x, dotMaskDomeTopLayer.position.y + dotMaskDomeTopLayer.bounds.size.height);
_dotMaskDomeFrontLayer.backgroundColor = dotMaskDomeTopLayer.backgroundColor;

//_dotLayer.mask = dotMaskDomeFrontLayer;
_dotLayer.mask = _dotMaskDomeFrontLayer;

_dotDomeLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize * 0.75];
_dotDomeLayer.backgroundColor = [_mapView.tintColor CGColor];
Expand Down

0 comments on commit f244254

Please sign in to comment.