【发布时间】:2016-07-26 19:41:30
【问题描述】:
我有一个要求,比如我当前的位置将显示一个视图。如果设备旋转或位置将改变,它将旋转。我研究了很多,但得到了所有在某个位置具有固定位置或角度但我没有固定位置的代码。谁能带我往正确的方向前进。
我还使用了 GMSMarker 的 rotation 属性,但它不起作用。
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
if (newHeading.headingAccuracy < 0){
NSLog(@"heading accuracy < 0");
return;
}
// Convert Degree to Radian and move the needle
float oldRad = (- manager.heading.trueHeading) * M_PI / 180.0f;
float newRad = (- newHeading.trueHeading) * M_PI / 180.0f;
// Compass animation
CABasicAnimation *theAnimation;
theAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
theAnimation.fromValue = [NSNumber numberWithFloat:oldRad];
theAnimation.toValue = [NSNumber numberWithFloat:newRad];
theAnimation.duration = 0.5f;
[source.layer addAnimation:theAnimation forKey:@"animateMyRotation"];
// source.transform = CGAffineTransformMakeRotation(newRad)
// GMSMarker *source = [googleMap selectedMarker];
// source.rotation = newRad;
}
更新:我有旋转方法,但有什么方法可以旋转 GMSMarker,因为没有变换方法。
优步如何在谷歌地图中旋转他们的汽车?
【问题讨论】:
-
degree应该是您为之前的航向度存储的一些变量。 -
@zcui93 但我第一次如何找到那个学位
-
您只需为其分配一个默认值,对应于加载时箭头的默认方向。
-
@chiragshah, jo baka thodi taklif to revani.. :)
-
@Hemang 请驯服 taklif thodi dur karo ne
标签: ios objective-c google-maps-markers cllocationmanager gmsmapview