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

ClusterKit incompatible with with MGLAnnotations? #66

Closed
makinggainz opened this issue Feb 27, 2019 · 5 comments
Closed

ClusterKit incompatible with with MGLAnnotations? #66

makinggainz opened this issue Feb 27, 2019 · 5 comments

Comments

@makinggainz
Copy link

So I am trying to implement the mapbox pods in order to cluster a bunch of customPointAnnotations which are in an array. The only problem is that on the line below:

mapView1.clusterManager.annotations = annotations
I get the following error:

Cannot assign value of type '[MGLAnnotation]' to type '[MKAnnotation]'

Does clusterkit not work with MGLAnnotations?

@maxep
Copy link
Contributor

maxep commented Feb 28, 2019

ClusterKit works with MKAnnotation but this is easily fixed by adding the compliance. MGLAnnotation and MKAnnotation are very close:

class YourAnnotation: NSObject, MGLAnnotation, MKAnnotation {
    ...
}

@makinggainz
Copy link
Author

@maxep I currently do not have my own custom class for my annotations. I must then create one? What content should it have inside? Could you point me to any examples of how this would be implemented?

@maxep
Copy link
Contributor

maxep commented Mar 1, 2019

MGLAnnotation like MKAnnotation are protocols, so you need to create a concrete type that complies to MKAnnotation to be used as an annotation in ClusterKit.
In the examples of this project, I use the MKPointAnnotation.

@makinggainz
Copy link
Author

makinggainz commented Mar 16, 2019

@maxep So I did this and also implemented the other pieces of functionality and it has not been working. I find that in the

func mapView(_ mapView: MGLMapView, didSelect annotation: MGLAnnotation) {
method I get nil when doing:
if let cluster = annotation as? CKCluster, cluster.count > 1 {
How do I fix this? I also asked a SO question if you would like to check it out.

I also did extension MapVC: MGLMapViewDelegate, MKMapViewDelegate { But that does not seem to help. Not sure if I need to do this or not.

@makinggainz
Copy link
Author

I believe my problem above has to do with the clustering not working at all so I opened a new issue for it. #68

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