Skip to content

hyperoslo/PinFloyd

 
 

Repository files navigation

PinFloyd

CI Status Version Carthage Compatible License Platform Swift

Description

MapKit annotations clustering for iOS.

Usage

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
}

Installation

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.

Author

Vadym Markov, markov.vadym@gmail.com

Credits

This library was originally done at Hyper, a digital communications agency with a passion for good code and delightful user experiences.

Contributing

Check the CONTRIBUTING file for more info.

License

PinFloyd is available under the MIT license. See the LICENSE file for more info.

Packages

No packages published

Languages

  • Swift 97.2%
  • Ruby 2.3%
  • Shell 0.5%