MKGeodesicPolyline

We knew that the Earth was not flat long before 1492. Early navigators observed the way ships would dip out of view over the horizon many centuries before the Age of Discovery.

MKGeodesicPolyline was introduced to the Map Kit framework in iOS 7. As its name implies, it creates a geodesic—essentially a straight line over a curved surface.

nshipster.com/mkgeodesicpolyline/

MKGeodesicPolyline, added in iOS 7, draws the true shortest path between points on the Earth’s curved surface. On a flat map this appears as a gentle arc instead of a straight line.

A normal straight MKPolyline from Los Angeles to New York looks wrong because it follows the flat projection. A geodesic polyline correctly curves northward, matching real great-circle flight routes.

It is rendered with the usual MKPolylineRenderer. Internally it consists of thousands of tiny segments so the curve stays accurate at any zoom level.

Common uses:

The result looks far more professional than a flat straight line, especially on long distances. It is a small change that makes a big visual difference.


Category:

Year: