Skip to content

erges/ClusteringMarkers

 
 

Repository files navigation

ClusteringMarkers

Version License Platform

Screen Shot

Usage

The main class used is Pin inherited from Marker. Pin contains object displayed on the map. You can put any class that conforms to the IPinObject protocol.

Clustering with data adapter:

    var stores: [Store] = [Store(), Store()]
        
    var mapDataAdapter = CMDataAdapter(mapView: mapView, delegate: self)
    //delegate — loading and tap markers notifications
        
    mapDataAdapter.setMarkers(with: stores, withMoveToBounds: true)

Customization:

Pins provides you to customize them using class inheritance. Use setCachedImage to cache repeated images for reuse.

Pin:

    override public func setIcon() {
        if let icon = IsSelected ? #your_selected_image : #your_image {
            Placemark?.setIconWith(icon)
        }
    }

Cluster:

Use styleCluster to customize the cluster generated by YandexMapKit.

Setup customization:

Inherit class CMDataAdapter.

    override func initiatePin(object: IPinObject) -> Pin? {
        return Pin(object)
    }

    override func styleCluster(with cluster: Cluster, imageCache: AutoPurgingImageCache?) {
        cluster.setCachedImage(withIdentifier: "\(cluster.size)", imageCache: imageCache) { () -> UIImage? in
            return ClusterView(number: cluster.size, displayedText: "\(cluster.size)").snapshot()
        }
    }

Example

To run the example project, clone the repo, and run pod install from the Example directory first. To enable the Yandex Map you should get API key from website and put it in AppDelegate.swift

Installation

ClusteringMarkers is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ClusteringMarkers'

Author

Aleksandr, [email protected]

License

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

About

Clustering markers using YandexMapKit

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 96.0%
  • Ruby 4.0%