Mapkit的ClusterKit无法正常工作?

时间:2019-03-17 02:43:18

标签: ios swift mapbox

因此,我尝试实现ClusterKit proj,以便在我的应用程序中将注释/(可能是多义线)(given that Mapbox does not have that functionality)聚类,但这似乎不起作用。没有错误或任何事情,它什么都不做,我不确定我在做什么错。

以下是相关代码:

    func setupCluster() {

            mapView1.clusterManager.marginFactor = 1
            print(ObjAnnotationArray.annotations, " These are teh annotations")
            mapView1.clusterManager.annotations = ObjAnnotationArray.annotations
    }
`    @nonobjc func mapView(_ mapView: MGLMapView, regionDidChangeAnimated animated: Bool) {
        print("Change ")
        mapView.clusterManager.updateClustersIfNeeded()
    }

这些是delagete方法,我在其中添加了指定的功能in the docs

`    func mapView(_ mapView: MGLMapView, didSelect annotation: MGLAnnotation) {

        print(annotation," ",(annotation as? CKCluster)?.count, " also: ",annotation as? CKCluster)

        if let cluster = annotation as? CKCluster, cluster.count > 1 {
            print("inside if the k=cluser functionaluty")

            let edgePadding = UIEdgeInsets(top: 40, left: 20, bottom: 44, right: 20)
            let camera = mapView.cameraThatFitsCluster(cluster, edgePadding: edgePadding)
            mapView.setCamera(camera, animated: true)
        }
}

{{1}}

有关如何解决此问题的帮助/建议?

我已经在their example看过这里,但是我自己找不到解决方案。

另外,here is the wiki关于如何执行我遵循的内容。

0 个答案:

没有答案