I have requirement like on my current location one view will display. It will rotate if device was rotate or location will be change.I research lot but got all the code which have a fix location or angle at some location but i haven't fix location. Can anyone drive me at right direction.
I also used rotation property of the GMSMarker but it is not working.
- (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;
}
Update: I have rotation method but is there any way to rotate the GMSMarker because there is no method for transform.
How uber rotate their car in google map?
degree
should be some variable you stored for previous heading degree. – Pinna