Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions OCMapView/OCMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

#import <MapKit/MapKit.h>
#import <AvailabilityMacros.h>

#import "OCDistance.h"
#import "OCAnnotation.h"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion OCMapView/OCMapView.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ - (void)sharedInit
_clusteringMethod = OCClusteringMethodBubble;
_clusterSize = 0.2;
_minLongitudeDeltaToCluster = 0.0;
_minLatitudeDeltaToCluster = 0.0;
_minimumAnnotationCountPerCluster = 0;
_clusteringEnabled = YES;
_clusterByGroupTag = NO;
Expand All @@ -59,6 +60,7 @@ - (void)sharedInit
@"clusterSize",
@"clusterByGroupTag",
@"minLongitudeDeltaToCluster",
@"minLatitudeDeltaToCluster",
@"minimumAnnotationCountPerCluster",
@"clusterInvisibleViews",
@"annotationsToIgnore"];
Expand Down Expand Up @@ -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;
Expand Down