Search code examples
iosios7mapkit

Difficulties understanding MapKit Coordinate System


I read the apple docs

"A map point is an x and y value on the Mercator map projection" A point is a graphical unit associated with the coordinate system of a UIView

What is the difference logically between a Point and a MKPoint? I obviously need CGPoint to display something on the screen. So why does MapKit need MKMapPoint?


Solution

  • The fact that both the CGPoint and MKMapPoint structs happen to store two floating-point values named x and y is irrelevant.

    They are given different names because they logically deal with different coordinate systems, transformations, ranges and scales.

    A 2D world map needs a large, fixed coordinate system that allows a latitude and longitude to be converted to a fixed point on the map regardless of what portion is currently being displayed on the screen.

    The range of MKMapPoint values are large since they need to represent the world's coordinates at a high-enough resolution (well beyond screen sizes).

    However, you don't exactly need to care about the actual values of an MKMapPoint. Occasionally, you may need to convert a CLLocationCoordinate2D to an MKMapPoint (or the other way around) but you don't need to worry about those values nor should you store them (the docs recommend not doing this since the internal projection calculations to convert a latitude and longitude to a 2D projection may change between iOS releases).

    Your usage of an MKMapPoint is only on the basis that you are dealing with the map's 2D projection independent of the device's screen size or what portion of the map is currently displaying.


    I obviously need CGPoint to display something on the screen.

    Yes but when adding annotations or overlays, you generally deal with CLLocationCoordinate2D values and let the map view do the conversion as needed.