CLLocationCoordinate2D distance between two points considering zoom level

I'm trying to create a solid clustering mechanism using a subclass of an MKMapView. I came across a task that have I've been banging my head against the wall for quite some time now - grouping annotations into a single cluster when they're overlapping with one another. I can get the distance in meters between two annotations, but how can I get that distance relative to a zoom level (latitudeDelta)? Ideally I would like to know when two annotations overlap with each other considering their width and height for example are 40x40.

Answers


You can use convertCoordinate:toPointToView: to get the location of the actual screen point for an annotation:

CGPoint annotationPoint = [self.mapView convertCoordinate:annotation.coordinate 
                                            toPointToView:self.mapView];

After that, use your trigonometry skills to find the distance between two points.


Need Your Help

Where to initialize an instance variable in a class

iphone objective-c

I'm new to objective-c and I always have problem with global variable . I don't know where to initialize them . My problem is with an NSString . I wrote this code –

Displaying Array Using Smarty Template?

php smarty

I'm trying to use Smarty to automatically insert data into a textarea.