-
Notifications
You must be signed in to change notification settings - Fork 86
GoogleMaps
Maxime edited this page Oct 17, 2017
·
1 revision
ClusterKit is available through CocoaPods. To install
it, simply add the following line to your Podfile
:
pod 'ClusterKit'
Then add the GMSMapView+ClusterKit
file manually.
With Carthage, add the following to your Cartfile
:
github "hulab/ClusterKit"
Note: These instructions are only for the case where you have a
Podfile
that declaresuse_frameworks!
in it. If yourPodfile
doesn't haveuse_frameworks!
in it, please use the'ClusterKit/GoogleMaps'
subspec directly:pod 'ClusterKit/GoogleMaps'
As GoogleMaps is still a static framework, ClusterKit for GoogleMaps is not available as a framework dependency. if you aim to integrate ClusterKit with GoogleMaps, you will need few more steps:
- In your project, create a group named
ClusterKit
. - Download
GMSMapView+ClusterKit.h
andGMSMapView+ClusterKit.m
fromClusterKit/GoogleMaps
. - Add the files to your project by right clicking on the
ClusterKit
group and selecting "Add Files to ..." (Make sure you select the target as your app target to avoid undefined symbols issue). -
In Swift projects: Add a bridging header file with
#import "GMSMapView+ClusterKit.h"
(note the relative path).
CKGridBasedAlgorithm *algorithm = [CKGridBasedAlgorithm new];
self.mapView.clusterManager.algorithm = algorithm;
self.mapView.dataSource = self;
self.mapView.clusterManager.annotations = annotations;
- (void)mapView:(GMSMapView *)mapView idleAtCameraPosition:(GMSCameraPosition *)position {
[mapView.clusterManager updateClustersIfNeeded];
}
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
if (marker.cluster.count > 1) {
GMSCameraUpdate *cameraUpdate = [GMSCameraUpdate fitCluster:marker.cluster];
[mapView animateWithCameraUpdate:cameraUpdate];
return YES;
}
return NO;
}
- (GMSMarker *)mapView:(GMSMapView *)mapView markerForCluster:(CKCluster *)cluster {
GMSMarker *marker = [GMSMarker markerWithPosition:cluster.coordinate];
if(cluster.count > 1) {
marker.icon = <#Cluster icon#>;
} else {
marker.icon = <#Annotation icon#>;
}
return marker;
}