How is MKMapCamera height calculated?

I look at the height of the camera MKMapViewwhen the view scrolls, and I find strange behavior: the height of the viewpoint fluctuates when the user scrolls, although the zoom level of the map remains the same.

After a closer inspection, it seems that the height decreases when the user scrolls south (to the equator), and increases again as soon as the user passes the equator. I thought that this could have something to do with the curvature of the Earth, and perhaps due to some knowledge of trigonometry or cartography that I don’t have.

I am trying to imitate this function. I have CLLocationCoordinate2Dboth the current level of height and scaling, and I want to calculate the correct height for MKMapCamera.

Thanks!

+4
source share
1 answer

I found your post asking the same question. I found this post:

How to determine the correct height for MKMapCamera, focusing on MKPolygon

Condensing this in response to my question (and mine):

    double distance = MKMetersBetweenMapPoints(MKMapPointForCoordinate(pinCenter.coordinate),
                                               MKMapPointForCoordinate(pinEye.coordinate));
    double altitude = distance / tan(M_PI*(15/180.0));

    MKMapCamera *camera = [MKMapCamera cameraLookingAtCenterCoordinate:pinCenter.coordinate
                                                     fromEyeCoordinate:pinEye.coordinate
                                                           eyeAltitude:altitude];
+4
source

Source: https://habr.com/ru/post/1527787/


All Articles