[ios] Clean-up user location annotation heading calculations
- Use MGLRadiansFromDegrees(). - Make indentation more readable.
This commit is contained in:
@@ -459,10 +459,11 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck
|
||||
|
||||
- (CGFloat)calculateAccuracyRingSize
|
||||
{
|
||||
CGFloat latRadians = self.userLocation.coordinate.latitude * M_PI / 180.0f;
|
||||
CGFloat pixelRadius = self.userLocation.location.horizontalAccuracy / cos(latRadians) / [self.mapView metersPerPointAtLatitude:self.userLocation.coordinate.latitude];
|
||||
CGFloat latitudeRadians = MGLRadiansFromDegrees(self.userLocation.coordinate.latitude);
|
||||
CGFloat metersPerPoint = [self.mapView metersPerPointAtLatitude:self.userLocation.coordinate.latitude];
|
||||
CGFloat pixelRadius = self.userLocation.location.horizontalAccuracy / cos(latitudeRadians) / metersPerPoint;
|
||||
|
||||
return pixelRadius * 2;
|
||||
return pixelRadius * 2.0;
|
||||
}
|
||||
|
||||
- (UIImage *)headingIndicatorTintedGradientImage
|
||||
@@ -479,8 +480,11 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck
|
||||
// gradient from the tint color to no-alpha tint color
|
||||
CGFloat gradientLocations[] = {0.0, 1.0};
|
||||
CGGradientRef gradient = CGGradientCreateWithColors(
|
||||
colorSpace, (__bridge CFArrayRef)@[(id)[self.mapView.tintColor CGColor],
|
||||
(id)[[self.mapView.tintColor colorWithAlphaComponent:0] CGColor]], gradientLocations);
|
||||
colorSpace,
|
||||
(__bridge CFArrayRef)@[
|
||||
(id)[self.mapView.tintColor CGColor],
|
||||
(id)[[self.mapView.tintColor colorWithAlphaComponent:0] CGColor]],
|
||||
gradientLocations);
|
||||
|
||||
// draw the gradient from the center point to the edge (full halo radius)
|
||||
CGPoint centerPoint = CGPointMake(haloRadius, haloRadius);
|
||||
@@ -513,8 +517,8 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck
|
||||
// clip the oval to ± incoming accuracy degrees (converted to radians), from the top
|
||||
[ovalPath addArcWithCenter:CGPointMake(CGRectGetMidX(ovalRect), CGRectGetMidY(ovalRect))
|
||||
radius:CGRectGetWidth(ovalRect) / 2.0
|
||||
startAngle:(-180 + clippingDegrees) * M_PI / 180
|
||||
endAngle:-clippingDegrees * M_PI / 180
|
||||
startAngle:MGLRadiansFromDegrees(-180 + clippingDegrees)
|
||||
endAngle:MGLRadiansFromDegrees(-clippingDegrees)
|
||||
clockwise:YES];
|
||||
|
||||
[ovalPath addLineToPoint:CGPointMake(CGRectGetMidX(ovalRect), CGRectGetMidY(ovalRect))];
|
||||
|
||||
Reference in New Issue
Block a user