https://github.com/vadymmarkov/pinfloyd
MapKit annotations clustering for iOS
https://github.com/vadymmarkov/pinfloyd
annotation cluster map mapkit render swift
Last synced: 6 months ago
JSON representation
MapKit annotations clustering for iOS
- Host: GitHub
- URL: https://github.com/vadymmarkov/pinfloyd
- Owner: vadymmarkov
- License: other
- Created: 2017-04-04T10:57:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-28T12:17:57.000Z (about 7 years ago)
- Last Synced: 2025-04-10T00:12:18.543Z (6 months ago)
- Topics: annotation, cluster, map, mapkit, render, swift
- Language: Swift
- Homepage: https://vadymmarkov.github.io
- Size: 67.4 KB
- Stars: 26
- Watchers: 3
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PinFloyd
[](https://travis-ci.org/vadymmarkov/PinFloyd)
[](http://cocoadocs.org/docsets/PinFloyd)
[](https://github.com/Carthage/Carthage)
[](http://cocoadocs.org/docsets/PinFloyd)
[](http://cocoadocs.org/docsets/PinFloyd)
## Description
MapKit annotations clustering for iOS.
## Usage
Create an instance of `ClusteringManager`:
```swift
let clusteringManager = ClusteringManager()
```Add annotations:
```swift
clusteringManager.add(annotations: annotations)
```Replace annotations:
```swift
clusteringManager.replace(annotations: annotations)
```Render annotations on region change:
```swift
// MKMapViewDelegate
func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
clusteringManager.renderAnnotations(onMapView: mapView)
}
```Reuse annotation view:
```swift
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
switch annotation {
case let annotation as ClusterAnnotation:
let id = ClusterAnnotationView.identifiervar 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](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'PinFloyd'
```**PinFloyd** is also available through [Carthage](https://github.com/Carthage/Carthage).
To install just write into your Cartfile:```ruby
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](http://hyper.no), a digital
communications agency with a passion for [good code](https://github.com/hyperoslo) and delightful user experiences.## Contributing
Check the [CONTRIBUTING](https://github.com/vadymmarkov/PinFloyd/blob/master/CONTRIBUTING.md) file for more info.
## License
**PinFloyd** is available under the MIT license. See the [LICENSE](https://github.com/vadymmarkov/PinFloyd/blob/master/LICENSE.md) file for more info.