Question

I am developing an iphone application,in that app i am showing the client Parking places in different locations on MKMapView. Now I need to use compass mode in MKMapView to show the client parking places in particular direction (SE,SW,NE,NW), for that I run this below code.

-(void)updateHeading:(CLHeading *) newHeading  
{ 

  NSLog(@"New magnetic heading: %f", newHeading.magneticHeading);
  NSLog(@"New true heading: %f", newHeading.trueHeading);

  double rotation = newHeading.magneticHeading * 3.14159/-180;

  [mapView setTransform:CGAffineTransformMakeRotation(-rotation)];

  [[mapView annotations] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop)
 {
    MKAnnotationView * view = [mapView viewForAnnotation:obj];

    [view setTransform:CGAffineTransformMakeRotation(rotation)];

 }];  
}

Everthing works fine in MKMapView, but my MKMapView shows in reverse order, when the device starts rotating, I am facing this problem in ios5 and ios6 also. NOTE: when I test this app in America, map shows correctly, while I test the app in my location (India) Map turns into reverse.

MKMapView shows reverse map, while device starts rotating. `

Thanks in advance for any help.

Was it helpful?

Solution

Is the map intended to be centered on the user while rotating? If so you could just set the MKMapView's userTrackingMode to MKUserTrackingModeFollowWithHeading.

If not then how about telling us what you see in magneticHeading, trueHeading and rotation when things go right and when they go wrong.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top