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

Overview

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.

Comments
  • Flickering pins on annotation updates

    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
    opened by mrylmz 11
  • custom annotation class

    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
    }
    

    } `

    opened by HaVaNa77 7
  • Can't implement :(

    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...

    opened by yetelday 7
  • Not able to try it

    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)
    
    opened by dneykov 6
  • Annotation and cluster views are actually re-created when scrolling the map but not re-used (Mapbox)

    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 :-)

    opened by Lawris 5
  • ClusterKit incompatible with with MGLAnnotations?

    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?

    opened by makinggainz 5
  • my custom annotation can not cast down CKCluster

    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 ?

    opened by mitty810609 5
  • Swift with GoogleMaps doesn't compile

    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
    
    opened by rujoota 5
  • This Framework is awesome!

    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

    opened by andre991 5
  • Add Swift Package Manager Support

    Add Swift Package Manager Support

    Issue Link :link:

    Fixes #77

    Goals :soccer:

    Add support of Swift Package Manager.

    Implementation Details :construction:

    • As ClusterKit is implemented in objc, the project needs to follow the C library structure:
        . 
        ├── Package.swift
        └── Sources 
             └── ClusterKit
               ├── **/*.m
               └── include 
                 ├── ClusterKit 
                 | └── *.h
                 └── module.modulemap
    
    • In order to be built by swift build (macOS), UIKit availability has to be checked using compile fag:
    #if __has_include(<UIKit/UIKit.h>)
    ...
    #endif
    
    • Replace #import "*.h" with module import #import <ClusterKit/*.h>.

    Testing Details :mag:

    Test suite is not yet available at swift test, tests will need to be re-rewritten in swift.

    opened by maxep 4
  • How to handle GMSCircle

    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.

    enhancement 
    opened by MarvinNazari 4
  • Stuttering on Mapbox since iOS14

    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.

    opened by Beniryu 2
  • mapView(_:didTap:) crashes randomly

    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.

    opened by Rakesh-iOS 1
  • GMSMapView+ClusterKit.swift

    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

    opened by KoCMoHaBTa 0
  • iOS 13 issues

    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

    opened by mihailsalari 0
Releases(0.5.0)
Owner
null
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

Lasha Efremidze 1.2k Dec 25, 2022
Allows you to use custom maps in iphone applications and attempts to mimics some of the behaviour of the MapKit framework

NAMapKit Lets you drop pins or custom annotations onto a standard UIImage or a tiled NATiledImageView. Includes callouts, multi-colored pins, animatio

Neil Ang 263 Jun 29, 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

Muhammad Abdul Subhan 48 Aug 13, 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. Installation Cocoapods pod 'JDSWiftHeatMap' Usage JDSwi

郭介騵 135 Dec 26, 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

Manu Martinez 0 Oct 19, 2021
MapKit, but for SwiftUI

MapKit, but for SwiftUI

Lawrence Bensaid 2 Jul 1, 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. Easily extensible annotations and overlays, iOS 13 support and backwards compatible with MKAnnotation and MKOverlay!

Paul 73 Dec 26, 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

Mapbox 4.2k Jan 9, 2023
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.

Dalton Claybrook 9 Apr 7, 2022
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

Rob Labs 0 Dec 30, 2021
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

Romain L 268 Aug 18, 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

Matt Greenfield 1.5k Jan 2, 2023
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

Mapbox 187 Dec 19, 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

Josef Moser 53 Feb 5, 2022
Demo in SwiftUI of Apple Map, Google Map, and Mapbox map

SNMapServices SNMapServices is a serices for iOS written in SwiftUI. It provides Map capability by subclassing Mapbox, Google map and Apple map. This

Softnoesis 3 Dec 16, 2022
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

Lasha Efremidze 1.2k Dec 25, 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

HongXing Liao 2 Dec 16, 2022
Allows you to use custom maps in iphone applications and attempts to mimics some of the behaviour of the MapKit framework

NAMapKit Lets you drop pins or custom annotations onto a standard UIImage or a tiled NATiledImageView. Includes callouts, multi-colored pins, animatio

Neil Ang 263 Jun 29, 2022
🗺️ 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

MAPS.ME 4.5k Dec 23, 2022
Creates SpriteKit game maps from TMX Map files.

PEMTileMap is a Swift package that generates SpriteKit game maps from TMX Map files. Maps, layers, tiles and objects are automatically rendered as SKN

hotdogsoup.nl 3 Jul 12, 2022