Save image in map frame (3d corner) on screen setVisibleMapRect

I am trying to focus my map display on a specific region, but in a way that does not break the current camera (angle of view). When I call setVisibleMapRect

, the camera is always reset and the view is completely top to bottom.

Is there a way to save the camera angle of the map or restore it after a call setVisibleMapRect

? I can't seem to get this to work for what I am trying to do. To be clear, I obviously don't want the exact same camera, because then the call setVisibleMapRect

would be pointless, but I want to keep the "relative angle" of the camera while still zooming in or out based on the given visible map rectangle.

I even went so far as to try and calculate the angle based height using some trigonometry, but I can't get it to work correctly by setting the camera right after the call setVisibleRect

. I am guessing they are not meant to be shared.

I'm trying to use setVisibleRect

with a custom camera - a bad idea? Should I just try to figure out the appropriate values ​​to set the camera? This is tricky because the camera properties are not intuitive and there doesn't seem to be a convenient helper method for focusing on a specific area or rectangle on the map when using a non-zero camera angle. Any pointers would be appreciated.

+3


source to share


1 answer


You can use MKMapCamera

to control height and height. You can read the camera settings before changing the rectangle and then set them again as soon as the new rectangle is set. This is how you created the camera:



        //create camera object
        MKMapCamera *newCamera=[[MKMapCamera alloc] init];

        //set a new camera angle
        [newCamera setCenterCoordinate:CLLocationCoordinate2DMake(lat,lon)];
        [newCamera setPitch:60.0];
        [newCamera setAltitude:100.0];
        [mapView setCamera:newCamera animated:YES];

      

+2


source







All Articles