What is the best way to use MKMapCamera
I found three ways to use MKMapCamera and I want to know which one is the most recommended. My goal is to keep an eye on the user and I want to update the camera every time the location is updated (so every second).
1.
MKMapCamera *newCamera = [MKMapCamera camera];
[newCamera setCenterCoordinate:newCoordinate];
[newCamera setPitch:60];
[newCamera setHeading:heading];
[newCamera setAltitude:eyeAltitude];
[mapView setCamera:newCamera];
2.
MKMapCamera *newCamera = [MKMapCamera cameraLookingAtCenterCoordinate:newCoordinate
fromEyeCoordinate:oldCoordinate
eyeAltitude:eyeAltitude];
[newCamera setPitch:pitch];
[mapView setCamera:newCamera];
3.
MKMapCamera *oldCamera = mapView.camera;
[oldCamera setCenterCoordinate:newCoordinate];
[oldCamera setPitch:60];
[oldCamera setHeading:heading];
[oldCamera setAltitude:eyeAltitude];
Does memory wise seem nr 3 the most worthy or is it a singleton class? In most examples, they use nr1.
For nr3, I cannot get the animation to work.
Thank!
+3
source to share
1 answer
Using MKMapCamera, you can set the orientation of the map without going into transformation in the view or even detecting the title of the users.
MKMapCamera *mapCamera = [[self.mvMap camera] copy];
[mapCamera setHeading:headingDegrees];
[self.mvMap setCamera:mapCamera animated:YES];
If you don't need animation, you can simply set a new title on the existing camera:
[self.mapView.camera setHeading:heading];
+2
source to share