Is there in Swift the possibility to cluster markers in MapKit? I know that it's possible in Google Maps SDK, but I can't find the same feature in MapKit. I've found some libraries for Obj-C, but nothing for Swift
These some of the libraries that I have found:
Display map or satellite imagery within your app, call out points of interest, and determine placemark information for map coordinates.
MapKit has supported overlays with several styling options for years. In iOS 16, we are improving our existing APIs to allow your overlays to seamlessly integrate with the map. Let's start with a quick recap of overlay levels. Overlays can be rendered at two different levels: above roads and above labels.
I translated FBAnnotationClustering to Swift:
https://github.com/ribl/FBAnnotationClusteringSwift
Works with MapKit
. It's a working sample project, and the readme includes some integration and usage instructions.
There's also an associated blog post giving background on why we chose FBAnnotationClustering (I liked it), and why we translated it to Swift (didn't feel like troubleshooting Objective-C if we ran into issues later).
http://ribl.co/blog/2015/05/28/map-clustering-with-swift-how-we-implemented-it-into-the-ribl-ios-app/
Use MKMarkerAnnotationViews for easy clustering. Here's an example of class I have, where you can set the clustering identifier.
Annotations with the same clustering identifier will automatically cluster.
class AnnotationView: MKMarkerAnnotationView {
override init(annotation: MKAnnotation?, reuseIdentifier: String?) {
super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
self.clusteringIdentifier = "AnnotationViewIdentifier"
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With