Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clustering for Mapbox not working #68

Open
makinggainz opened this issue Mar 17, 2019 · 1 comment
Open

clustering for Mapbox not working #68

makinggainz opened this issue Mar 17, 2019 · 1 comment

Comments

@makinggainz
Copy link

makinggainz commented Mar 17, 2019

So I have tried implementing the ClusterKit proj in order to have clustering of annotations/(possibly polylines)(given that Mapbox does not have that functionality) in my app but it does not seem to work. No errors or anything it just does nothing and I am unsure what I am doing wrong.

Here is the relevant code:

 viewDidLoad() {
        let algorithm = CKNonHierarchicalDistanceBasedAlgorithm()
        algorithm.cellSize = 200
        mapView1.clusterManager.algorithm = algorithm
        fetchData() //This is a call to firebase I add the annotations to an  array of them inside an annotations object. 
        setupCluster() //This gest called multiple times IDK why, not sure if its the issue but I have been unable to change this
  }

    func setupCluster() {

            mapView1.clusterManager.marginFactor = 1
            print(ObjAnnotationArray.annotations, " These are teh annotations")
            mapView1.clusterManager.annotations = ObjAnnotationArray.annotations
    }

These are the delagete methods whwere I added functionality as specified in the docs.

`    @nonobjc func mapView(_ mapView: MGLMapView, regionDidChangeAnimated animated: Bool) {
        print("Change ")
        mapView.clusterManager.updateClustersIfNeeded()
    }
`    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)
        }
}

Any help/suggestions on how to solve this?

I have looked here at their example but cant find a solution there myself.

Also, here is the wiki on how to implement which I followed.

@makinggainz makinggainz changed the title Implementing clusterKit for Mapbox not working clustering not working for Mapbox not working Mar 17, 2019
@makinggainz makinggainz changed the title clustering not working for Mapbox not working clustering for Mapbox not working Apr 3, 2019
@Shwetank97
Copy link

I've also tried making use of this third party to create clusters of the annotation views, but nothing happens. No errors or anything are shown either?
Has this issue been resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants