ClusteringMarkers 1.5.1

ClusteringMarkers 1.5.1

维护者:Aleksandr Smorodov.



 
依赖项
YandexMapKit>= 0
AlamofireImage>= 4
 

  • 作者:
  • Aleksandr

ClusteringMarkers

Version License Platform

Screen Shot

使用方法

主要使用的类是继承自 Marker 的 Pin。Pin 包含在地图上显示的对象。您可以放任何符合 IPinObject 协议的类。

使用数据适配器进行聚合

    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 允许您通过类继承来自定义它们。使用 setCachedImage 方法来缓存重复使用的图像。

Pin

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

Cluster

使用 styleCluster 方法来自定义 YandexMapKit 生成的聚合。

设置自定义

继承 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 目录运行 pod install。要启用 Yandex 地图,您应从网站获取 API 键并将其放入 AppDelegate.swift。

安装

ClusteringMarkers 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod 'ClusteringMarkers'

作者

Aleksandr,[email protected]

许可

ClusteringMarkers 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。