12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #import "CCHCenterOfMassMapClusterer.h"
- @implementation CCHCenterOfMassMapClusterer
- - (CLLocationCoordinate2D)mapClusterController:(CCHMapClusterController *)mapClusterController coordinateForAnnotations:(NSSet *)annotations inMapRect:(MKMapRect)mapRect
- {
- double latitude = 0, longitude = 0;
- for (id<MKAnnotation> annotation in annotations) {
- latitude += annotation.coordinate.latitude;
- longitude += annotation.coordinate.longitude;
- }
-
- CLLocationCoordinate2D coordinate;
- if (annotations.count > 0) {
- double count = (double)annotations.count;
- coordinate = CLLocationCoordinate2DMake(latitude / count, longitude / count);
- } else {
- coordinate = CLLocationCoordinate2DMake(0, 0);
- }
-
- return coordinate;
- }
- @end
|