What is the difference between MKCoordinateSpan and CLLocationCoordinate2D

I was looking at a sample MapKit and CoreLocation structure example. I found these two structures ( MKCoordinateSpan and CLLocationCoordinate2D ) similar in the declaration. As they differ in functionality, someone can please the site with an example (using both) to clear their values.

Thanks!

+7
source share
2 answers

MKCoordinateSpan defines a range, i.e. delta, in the directions of latitude and longitude, which should be displayed on the map. Along with the point, you can then determine the region to display on the map.

CLLocationCoordinate2D defines a single point in the latitude and longitude coordinate system.

For example:

 |<---- deltaLat ---->| |---------------------|--- | | | | | | | | | | | | | + |deltaLon | (lat,lon) | | | | | | | | | | | |---------------------|--- 

Here you can imagine the center point (lat,lon) about which you have deltaLat and deltaLon .

So, (lat,lon) will be CLLocationCoordinate2D , and deltaLat, deltaLon will form a MKCoordinateSpan .

You are right that both structures are defined identically, but it is quite common when two different structures have different semantics and therefore are defined separately, as you have already found.

+22
source

MKCoordinateSpan interpreted as delta values, while CLLocationCoordinate2D interpreted as a point.

For example, let's say you want to define a circular region, you would define the center point and the radius around it.

In MapKit you define a rectangular area on MKCoordinateRegion . The center point is CLLocationCoordinate2D ( latitude and longitude are both typedef double ) and the vertical and horizontal deltas on MKCoordinateSpan ( latitudeDelta and longitudeDelta are both typedef double values)

+6
source

All Articles