MapKit annotations clustering for iOS.
Create an instance of ClusteringManager
:
let clusteringManager = ClusteringManager()
Add annotations:
clusteringManager.add(annotations: annotations)
Replace annotations:
clusteringManager.replace(annotations: annotations)
Render annotations on region change:
// MKMapViewDelegate
func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
clusteringManager.renderAnnotations(onMapView: mapView)
}
Reuse annotation view:
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
switch annotation {
case let annotation as ClusterAnnotation:
let id = ClusterAnnotationView.identifier
var clusterView = mapView.dequeueReusableAnnotationView(withIdentifier: id)
if clusterView == nil {
clusterView = ClusterAnnotationView(annotation: annotation, reuseIdentifier: id)
} else {
clusterView?.annotation = annotation
}
return clusterView
default:
// return annotation view
}
PinFloyd is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'PinFloyd'
PinFloyd is also available through Carthage. To install just write into your Cartfile:
github "vadymmarkov/PinFloyd"
PinFloyd can also be installed manually. Just download and drop Sources
folders in your project.
Vadym Markov, markov.vadym@gmail.com
This library was originally done at Hyper, a digital communications agency with a passion for good code and delightful user experiences.
Check the CONTRIBUTING file for more info.
PinFloyd is available under the MIT license. See the LICENSE file for more info.