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.
var stores: [Store] = [Store(), Store()]
var mapDataAdapter = CMDataAdapter(mapView: mapView, delegate: self)
//delegate — loading and tap markers notifications
mapDataAdapter.setMarkers(with: stores, withMoveToBounds: true)
Pins provides you to customize them using class inheritance.
Use setCachedImage
to cache repeated images for reuse.
override public func setIcon() {
if let icon = IsSelected ? #your_selected_image : #your_image {
Placemark?.setIconWith(icon)
}
}
Use styleCluster
to customize the cluster generated by YandexMapKit.
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()
}
}
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
ClusteringMarkers is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'ClusteringMarkers'
Aleksandr, [email protected]
ClusteringMarkers is available under the MIT license. See the LICENSE file for more info.