An iOS map clustering framework targeting MapKit, Google Maps and Mapbox.

Last update: May 27, 2022

CI Status Version License Platform Swift Package Manager Carthage


ClusterKit is an elegant and efficiant clustering controller for maps. Its flexible architecture make it very customizable, you can use your own algorithm and even your own map provider.

Features

  • Native supports of MapKit, GoogleMaps, Mapbox and YandexMapKit.
  • Comes with 2 clustering algorithms, a Grid Based Algorithm and a Non Hierarchical Distance Based Algorithm.
  • Annotations are stored in a QuadTree for efficient region queries.
  • Cluster center can be switched to Centroid, Nearest Centroid, Bottom.
  • Handles pin selection as well as drag and dropping.
  • Written in Objective-C with full Swift interop support.
MapKit GoogleMaps Mapbox
MapKit GoogleMaps Mapbox

Installation & Usage

Please follow the wiki for integration.

If you want to try it, simply run:

pod try ClusterKit

Or clone the repo and run pod install from the Examples directory first.

Provide the Google API Key in the AppDelegate in order to try it with GoogleMaps.

Provide the Mapbox Access Token in the AppDelegate in order to try it with Mapbox.

Provide the Yandex API Key in the AppDelegate in order to try it with YandexMapKit.

Credits

Assets by Hugo des Gayets.

Thanks @petropavel13 for the YandexMapKit integration.

License

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

GitHub

https://github.com/hulab/ClusterKit
Comments
  • 1. Flickering pins on annotation updates

    ClusterKit is causing a flickering issue on custom annotation views using MapKit.

    I have tried solving this issue by using: - addAnnotations(...) and - removeAnnotations(...), but that doesn't seam to solve the problem.

    I'm calling - updateClustersIfNeeded in -mapView(_:, regionDidChangeAnimated:) as described in the documentation.

    Tested with:

    • iOS Version 11.0 GM Seed
    Reviewed by mrylmz at 2017-09-18 12:59
  • 2. custom annotation class

    hi, first of all this extension is great! But for now i 'm not able to get it works:

    I have a custom class for annotations, i added CKAnnotation as another issue suggested me, but when i try to add an annotation to cluster:

    self.mapView.clusterManager.annotations = annotation

    i get: can not assign value of type MyAnnotation to CKAnnotation.

    What's wrong?

    here's the code:

    ` import UIKit import MapKit import ClusterKit

    class MyAnnotations: NSObject, MKAnnotation, CKAnnotation{

    weak public var cluster: CKCluster?
    
    
    var coordinate: CLLocationCoordinate2D
    var title: String?
    var subtitle: String?
    var name: String?
    var size: String?
    var user: String?
    var owner: String?
    var image: String?
    var latLoc: Double?
    var lonLoc: Double?
    var itemId: String?
    
    init(coordinate: CLLocationCoordinate2D) {
        self.coordinate = coordinate
    }
    

    } `

    Reviewed by HaVaNa77 at 2017-07-19 13:58
  • 3. Can't implement :(

    Hi, I'm trying to implement the library but I'm stuck, I have an array of MKAnnotation for my locations but the cluestermanager expects CKAnnotation objects...

    Reviewed by yetelday at 2017-02-06 11:23
  • 4. Not able to try it

    Hi,

    I'm want to give your framework a try but I'm not able to install it pod install gives following errors:

    Fetching podspec for `ClusterKit` from `../.`
    [!] The following pods are integrated into targets that do not have the same Swift version:
    
    - ClusterKit/Core required by Example-objc (Swift 3.0), Example-swift (Swift 4.0)
    - ClusterKit/MapKit required by Example-objc (Swift 3.0), Example-swift (Swift 4.0)
    - ClusterKit/Mapbox required by Example-objc (Swift 3.0), Example-swift (Swift 4.0)
    - Mapbox-iOS-SDK required by Example-objc (Swift 3.0), Example-swift (Swift 4.0)
    - GoogleMaps required by Example-objc (Swift 3.0), Example-swift (Swift 4.0)
    - GoogleMaps/Base required by Example-objc (Swift 3.0), Example-swift (Swift 4.0)
    - GoogleMaps/Maps required by Example-objc (Swift 3.0), Example-swift (Swift 4.0)
    
    Reviewed by dneykov at 2017-12-05 07:31
  • 5. Annotation and cluster views are actually re-created when scrolling the map but not re-used (Mapbox)

    Hello,

    Using the example project in Swift for MapBox (modifying it a little bit for troubleshooting), I found that when I scroll the map to some point and then get back to the initial position, annotations views are always re-created but not loaded through dequeueReusableAnnotationView().

    viewsReacreated

    As you can see, in the first place single annotation and cluster views exist. But then, scrolling somewhere seems to "delete" the created views, because when I scroll back to the initial position, annotations and clusters views are re-created.

    Screenshot 2019-05-18 at 12 31 43

    Here I took the example of annotations (blue markers), I print something when the annotationView that should be loaded using dequeueReusableAnnotationView() is nil. As you can see, every annotation view is re-created.

    Am I missing something or is this a bug indeed?

    Same thing is happening for Apple's Mapkit.

    Any help is really appreciated, thank you :-)

    Reviewed by Lawris at 2019-05-18 11:01
  • 6. ClusterKit incompatible with with MGLAnnotations?

    So I am trying to implement the mapbox pods in order to cluster a bunch of customPointAnnotations which are in an array. The only problem is that on the line below:

    mapView1.clusterManager.annotations = annotations I get the following error:

    Cannot assign value of type '[MGLAnnotation]' to type '[MKAnnotation]'

    Does clusterkit not work with MGLAnnotations?

    Reviewed by makinggainz at 2019-02-27 22:26
  • 7. my custom annotation can not cast down CKCluster

    This is my custom annotation

    class CafeShopAnnotation: MKPointAnnotation {
        override var coordinate: CLLocationCoordinate2D {
            get {
                return CLLocationCoordinate2DMake(self.latitude, self.longitude)
            }
            set {
                self.coordinate = newValue
            }
        }
        override var title: String? {
            get {
                return self.name
            }
            set {
                self.title = newValue
            }
        }
        override var subtitle: String? {
            get {
                return self.address
            }
            set {
                self.subtitle = newValue
            }
        }
        
        var id = ""
        var city = ""
        var name = ""
        var wifi = Double()
        var seat = Double()
        var quiet = Double()
        var tasty = Double()
        var cheap = Double()
        var music = Double()
        var address = ""
        var latitude = Double()
        var longitude = Double()
        var url = ""
        var limited_time = ""
        var socket = ""
        var standing_desk = ""
        var mrt = ""
        var open_time = ""
        
    }
    
    

    In viewdidload i will handle my store class transform to custom annotation

    but view for annotation cast ckcluster fail

    what should i do ?

    Reviewed by mitty810609 at 2017-07-25 12:03
  • 8. Swift with GoogleMaps doesn't compile

    I am trying to work run the example project but it fails with this error:

    dyld: Library not loaded: @rpath/GeoJSONSerialization.framework/GeoJSONSerialization

    Also, when I tried setting up my own swift project, I get following compile time error:

    Value of type 'GMSMapView' has no member 'clusterManager'

    Here is my podfile:

    # Uncomment this line to define a global platform for your project
    # platform :ios, '9.0'
    
    target 'mapcluster' do
      # Comment this line if you're not using Swift and don't want to use dynamic frameworks
      use_frameworks!
    
      # Pods for mapcluster
      pod 'ClusterKit'
      pod 'GoogleMaps', '~> 2.2'
      pod 'ClusterKit/MapKit'
    end
    
    Reviewed by rujoota at 2017-06-30 02:57
  • 9. This Framework is awesome!

    Hi, firstly congratulation to create this framework, the best of all! I would like to know if you can put the number of pins inside a cluster, just like this one here. Thanks. example

    Reviewed by andre991 at 2017-01-20 13:21
  • 10. How to handle GMSCircle

    HI, awesome framework, really easy to handle clustering, I'm interested to know if u have some suggestion how u would handle adding circles for the pin, in my case is basically accuracy circle which I use GMSCircle to show that. But with cluster GMSMapViewDataSource there is no way to add the circle, I wonder if u know any workaround for any delegates call that I can use to add the circles my self, I only want to add the circles when the pins are unclustred.

    Thanks.

    Reviewed by MarvinNazari at 2017-11-20 10:13
  • 11. Show Total Pins

    Hi, I have checked the library but I didn't found how I can put the total number of map PIN covered in the region as compared to other libraries so please let me know if your library provides a way to achieve the same.

    Thanks

    Reviewed by Rahulgupta-cdnsol at 2017-11-04 13:07
  • 12. Stuttering on Mapbox since iOS14

    Hello,

    Thanks guys for building this amazing lib!

    Mapbox has been stuttering since iOS14. The issue has supposedly been resolved in Mapbox 6.2. https://github.com/mapbox/mapbox-gl-native-ios/issues/350

    However, I can't update mapbox to 6.2 because of ClusterKit.

    Do you think you'll update ClusterKit to be compatible with Mapbox 6.x soon?

    It's critical as my app is already on the store and it's a severe issue.

    Reviewed by Beniryu at 2020-12-14 20:59
  • 13. mapView(_:didTap:) crashes randomly

    Hi I am getting this crash randomly on Production live app.

    Here is the code snippet: func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {

        if marker.responds(to: #selector(getter: GMSMarker.cluster)) {
                   if let cluster = marker.cluster, cluster.count > 1 { **// crash strack trace indicating this line where crash happen**
                       OperationQueue.main.addOperation {
                           let cameraUpdate = GMSCameraUpdate.fit(marker.cluster!)
                           mapView.animate(with: cameraUpdate)
                       }
                       return true
                   }
        }
    

    }

    ClusterKit version: 0.5.0 GoogleMapExtension: "GMSMapView+ClusterKit.h"

    Screenshot 2020-10-13 at 11 04 52 AM

    This is Firebase crash report :

    Screenshot 2020-10-13 at 10 23 41 AM

    Please help me out. It would be highly appreciated as I'm getting this crash from last 4 - 5 releases.

    Reviewed by Rakesh-iOS at 2020-10-13 05:42
  • 14. GMSMapView+ClusterKit.swift

    If you wish to add swift version of GMSMapView+ClusterKit. It is much more convenient to drop-in this swift file instead of the ObjC when you don't have a bridging header.

    https://gist.github.com/KoCMoHaBTa/d92ea94515fcfdb11e975f9bf63b09f1

    Reviewed by KoCMoHaBTa at 2020-06-05 13:09
  • 15. iOS 13 issues

    Hi Guys, Thank you for your easy implementation of clustering, but seems on iOS 13 it not works perfectly, can you please come with some updates(you can check it on iOS 13) ASAP?

    Regards

    Reviewed by mihailsalari at 2019-11-28 14:34
MSFlightMapView allows you to easily add and animate geodesic flights to Google map

MSFlightMapView Demo Requirements iOS 10.0+ Xcode 9.0+ Installation Just add the MSFlightMapView folder to your project. or use CocoaPods: pod 'MSFlig

Apr 24, 2022
JDSwiftMap is an IOS Native MapKit Library. You can easily make a highly customized HeatMap.
JDSwiftMap is an IOS Native MapKit Library.  You can easily make a highly customized HeatMap.

JDSwiftMap is an IOS Native MapKit Library. You can easily make a highly customized HeatMap. Installation Cocoapods pod 'JDSWiftHeatMap' Usage JDSwi

Jun 18, 2022
Example app using MessagesUI + CoreLocation + MapKit

iOS Example MapKit App Ejemplo de código de una aplicación de mapas usando MessagesUI, MapKit y CoreLocation Built using XCode 13.0 (Swift 5) ¿Cómo ej

Oct 19, 2021
MapKit, but for SwiftUI

MapKit, but for SwiftUI

Apr 5, 2022
MKMapView wrapper for SwiftUI as drop-in to MapKit's SwiftUI view
MKMapView wrapper for SwiftUI as drop-in to MapKit's SwiftUI view

MKMapView wrapper for SwiftUI as drop-in to MapKit's SwiftUI view. Easily extensible annotations and overlays, iOS 13 support and backwards compatible with MKAnnotation and MKOverlay!

Jun 22, 2022
Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL

Mapbox GL Native A C++ library that powers customizable vector maps in native applications on multiple platforms by taking stylesheets that conform to

Jun 23, 2022
Use Swift in the macOS command line to build maps.
Use Swift in the macOS command line to build maps.

Use Swift in the macOS command line to build maps. imagefrom A Swift command line utility that gets an image from a URL. Saves the web image as JPEG o

Dec 30, 2021
A Swift package for parsing Clang module map files

Clangler is a Swift package used to parse Clang module map files into an abstract syntax tree (AST) representation. Once parsed, you can inspect or manipulate the nodes in the file, then generate and save a new file reflecting your changes.

Apr 7, 2022
Google Directions API helper for iOS, written in Swift
Google Directions API helper for iOS, written in Swift

PXGoogleDirections Google Directions API SDK for iOS, entirely written in Swift. ?? Features Supports all features from the Google Directions API as o

Mar 11, 2022
Location, motion, and activity recording framework for iOS

LocoKit A Machine Learning based location recording and activity detection framework for iOS. Location and Motion Recording Combined, simplified Core

Jun 13, 2022
A spatial analysis library written in Swift for native iOS, macOS, tvOS, watchOS, and Linux applications, ported from Turf.js.

Turf for Swift ?? ?? ?? ?? ⌚️ A spatial analysis library written in Swift for native iOS, macOS, tvOS, watchOS, and Linux applications, ported from Tu

Jun 16, 2022
A Swift wrapper for forward and reverse geocoding of OpenStreetMap data

Nominatim NominatimKit is a Swift wrapper for forward and reverse geocoding of OpenStreetMap data. Why? Geocoding location data on iOS requires the us

Feb 5, 2022
Easy Map Annotation Clustering 📍
Easy Map Annotation Clustering 📍

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

Jun 20, 2022
An exercise to use a map(google map) for navigation.

map-navigation An exercise to use a map(google map) for navigation. It have the features of navigating your for a destination, drawing your travel pat

May 30, 2022
🗺️ MAPS.ME — Offline OpenStreetMap maps for iOS and Android
🗺️ MAPS.ME — Offline OpenStreetMap maps for iOS and Android

MAPS.ME MAPS.ME is an open source cross-platform offline maps application, built on top of crowd-sourced OpenStreetMap data. It was publicly released

Jun 20, 2022
Card-based view controller for apps that display content cards with accompanying maps, similar to Apple Maps.

TripGo Card View Controller This is a repo for providing the card-based design for TripGo as well as the TripKitUI SDK by SkedGo. Specs 1. Basic funct

May 26, 2022
iOS - Subclass of UITextField to achieve autocompletion for Place Search like Google Places, Uber and Much more apps having maps.

MVAutocompletePlaceSearchTextField iOS - Subclass of UITextField to achieve autocompletion for Place Search like Google Places, Uber and Much more app

May 27, 2022
MSFlightMapView allows you to easily add and animate geodesic flights to Google map

MSFlightMapView Demo Requirements iOS 10.0+ Xcode 9.0+ Installation Just add the MSFlightMapView folder to your project. or use CocoaPods: pod 'MSFlig

Apr 24, 2022
GoogleMapsApp - Google Maps App With Swift
GoogleMapsApp - Google Maps App With Swift

googleMapsApp Тестовое задание Current location: Import points from servers:

Jan 11, 2022
An easy to integrate Model Based Google Maps Helper (SVHTTPClient, AFNetworking) That lets you Geo Code , Reverse Geocode, Get Directions , Places Autocomplete.

GoogleMapsHelper Read Me in Russian : http://gargo.of.by/googlemapshelper/ A GOOGLE MAPS Helper that help you do multiple tasks like HOW TO USE // usi

Feb 21, 2019