1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #import "CCHMapClusterAnnotation.h"
- #import "CCHMapClusterControllerDelegate.h"
- #import "CCHMapClusterControllerUtils.h"
- @implementation CCHMapClusterAnnotation
- - (NSString *)title
- {
- if (_title == nil && [self.delegate respondsToSelector:@selector(mapClusterController:titleForMapClusterAnnotation:)]) {
- _title = [self.delegate mapClusterController:self.mapClusterController titleForMapClusterAnnotation:self];
- }
- return _title;
- }
- - (NSString *)subtitle
- {
- if (_subtitle == nil && [self.delegate respondsToSelector:@selector(mapClusterController:subtitleForMapClusterAnnotation:)]) {
- _subtitle = [self.delegate mapClusterController:self.mapClusterController subtitleForMapClusterAnnotation:self];
- }
-
- return _subtitle;
- }
- - (BOOL)isCluster
- {
- return (self.annotations.count > 1);
- }
- - (BOOL)isUniqueLocation
- {
- return CCHMapClusterControllerIsUniqueLocation(self.annotations);
- }
- - (BOOL)isOneLocation
- {
- return [self isUniqueLocation];
- }
- - (MKMapRect)mapRect
- {
- MKMapPoint clusterPoint = MKMapPointForCoordinate(self.coordinate);
- MKMapRect mapRect = MKMapRectMake(clusterPoint.x, clusterPoint.y, 0.1, 0.1);
- for (id<MKAnnotation> annotation in self.annotations)
- {
- MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
- MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0.1, 0.1);
- mapRect = MKMapRectUnion(mapRect, pointRect);
- }
-
- return mapRect;
- }
- @end
|