diff --git a/OCMapView/OCMapView.h b/OCMapView/OCMapView.h index cbcc9fa..016c4d4 100644 --- a/OCMapView/OCMapView.h +++ b/OCMapView/OCMapView.h @@ -6,6 +6,7 @@ // #import +#import #import "OCDistance.h" #import "OCAnnotation.h" @@ -52,10 +53,16 @@ default: 0.2*/ @property(nonatomic, assign) BOOL clusterByGroupTag; // -/// Defines the "zoom" from where the map should start clustering. +/// Defines the "zoom" from where the map should start clustering, referenced by Longitude. /** If the map is zoomed below this value it won't cluster. default: 0.0 (no min. zoom)*/ -@property(nonatomic, assign) CLLocationDegrees minLongitudeDeltaToCluster; +@property(nonatomic, assign) CLLocationDegrees minLongitudeDeltaToCluster DEPRECATED_MSG_ATTRIBUTE("Use minLatitudeDeltaToCluster instead."); + +// +/// Defines the "zoom" from where the map should start clustering, referenced by Latitude. +/** If the map is zoomed below this value it won't cluster. + default: 0.0 (no min. zoom)*/ +@property(nonatomic, assign) CLLocationDegrees minLatitudeDeltaToCluster; // /// Defines how many annotations are needed to build a cluster diff --git a/OCMapView/OCMapView.m b/OCMapView/OCMapView.m index e3f1ff4..f48f726 100644 --- a/OCMapView/OCMapView.m +++ b/OCMapView/OCMapView.m @@ -47,6 +47,7 @@ - (void)sharedInit _clusteringMethod = OCClusteringMethodBubble; _clusterSize = 0.2; _minLongitudeDeltaToCluster = 0.0; + _minLatitudeDeltaToCluster = 0.0; _minimumAnnotationCountPerCluster = 0; _clusteringEnabled = YES; _clusterByGroupTag = NO; @@ -59,6 +60,7 @@ - (void)sharedInit @"clusterSize", @"clusterByGroupTag", @"minLongitudeDeltaToCluster", + @"minLatitudeDeltaToCluster", @"minimumAnnotationCountPerCluster", @"clusterInvisibleViews", @"annotationsToIgnore"]; @@ -168,7 +170,7 @@ - (void)doClusteringNow // Cluster annotations, when enabled and map is above the minimum zoom NSArray *clusteredAnnotations; - if (_clusteringEnabled && (self_region.span.longitudeDelta > _minLongitudeDeltaToCluster)) + if (_clusteringEnabled && (self_region.span.longitudeDelta > _minLongitudeDeltaToCluster) && (self_region.span.latitudeDelta > _minLatitudeDeltaToCluster) ) { //calculate cluster radius CLLocationDistance clusterRadius = self_region.span.longitudeDelta * _clusterSize;