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

Commit

Permalink
[ios] Apply perspective to x-free annotation views
Browse files Browse the repository at this point in the history
Working towards #5090.
  • Loading branch information
1ec5 committed Jun 24, 2016
1 parent 4eba5be commit bdff7d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion platform/ios/app/MBXAnnotationView.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ - (void)layoutSubviews {

- (nullable id<CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)event
{
if ([event isEqualToString:@"position"])
if ([event isEqualToString:@"transform"] || [event isEqualToString:@"position"])
{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:event];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
Expand Down
7 changes: 6 additions & 1 deletion platform/ios/src/MGLAnnotationView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,19 @@ - (void)setCenter:(CGPoint)center direction:(CLLocationDirection)direction pitch
CATransform3D t = CATransform3DIdentity;
if (pitch >= 0 && (self.freeAxes & MGLAnnotationViewBillboardAxisX))
{
// https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/AdvancedAnimationTricks/AdvancedAnimationTricks.html#//apple_ref/doc/uid/TP40004514-CH8-SW13
// FIXME: This is a rough, eyeballed value. Replace this transform with one derived from mbgl::TransformState::coordinatePointMatrix().
CGRect superBounds = self.superview.bounds;
t.m34 = -1.0 / (1000 - CGRectGetWidth(superBounds));

t = CATransform3DRotate(t, MGLRadiansFromDegrees(pitch), 1.0, 0, 0);
}
if (direction >= 0 && (self.freeAxes & MGLAnnotationViewBillboardAxisY))
{
t = CATransform3DRotate(t, MGLRadiansFromDegrees(-direction), 0.0, 0.0, 1.0);
}
self.layer.transform = t;

if (self.scalesWithViewingDistance)
{
[self updateScaleForPitch:pitch];
Expand Down

0 comments on commit bdff7d7

Please sign in to comment.