Skip to content

assisjeferson/Cluster

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

32 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Cluster

Language Version License Platform Carthage compatible

Cluster is an easy map annotation clustering library. This repository uses an efficient method (QuadTree) to aggregate pins into a cluster.

You may want to see the Example first if you'd like to see the actual code.

$ pod try Cluster

Requirements

  • iOS 8.0+
  • Xcode 8.0+
  • Swift 3.0+

Usage

Follow the instructions below:

Step 1: Initialize a ClusterManager object

let clusterManager = ClusterManager()

Step 2: Add annotations

let annotation = Annotation()
annotation.coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
clusterManager.add(annotation)

Step 3: Return the pins and clusters

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
    var view = mapView.dequeueReusableAnnotationView(withIdentifier: identifier)
    if view == nil {
        view = ClusterAnnotationView(annotation: annotation, reuseIdentifier: identifier, type: .color(color: color, radius: radius))
    } else {
        view?.annotation = annotation
    }
    return view
}

Step 4: Reload the annotations

func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
    clusterManager.reload(mapView)
}

Installation

CocoaPods

To install with CocoaPods, simply add this in your Podfile:

use_frameworks!
pod "Cluster"

Carthage

To install with Carthage, simply add this in your Cartfile:

github "efremidze/Cluster"

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Credits

https://github.com/ribl/FBAnnotationClusteringSwift

License

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

About

Easy Map Annotation Clustering ๐Ÿ“

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 93.3%
  • Ruby 4.1%
  • Objective-C 2.6%