我有我的要求就像當前位置一個視圖將顯示。它會旋轉,如果設備是旋轉或位置將改變。我研究很多,但得到的所有代碼有固定的位置或角度在某個位置,但我沒有修復位置。任何人都可以在正確的方向驅動我。旋轉GMSMarker的方向用戶面對
我也用輪轉屬性的GMSMarker,但它不工作。
- (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因爲對於變換沒有方法。
他們在谷歌地圖上旋轉他們的車怎麼樣?
旋轉圖像'度'應該是您爲之前的標題度儲存的一些變量。 – zcui93
@ zcui93,但在第一次我怎麼找到那個程度 –
你只是給它分配一個默認值,對應你裝載時的默認箭頭方向。 – zcui93