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

MemberAnnotations: Unrecognized selector sent to instance (Exception) #19

Open
jasanchezsa opened this issue Feb 10, 2019 · 1 comment

Comments

@jasanchezsa
Copy link

Hello good day,

First congratulations for the project. Excuse my English.

Three questions:

1.- How can I configure the design of the cluster view?
2.- Is it necessary to register ClusterAnnotationView?

mapView.register(ClusterAnnotationView.self, forAnnotationViewWithReuseIdentifier: ClusterAnnotationView.identifier)

3.- What happens when the annotation is of type MKClusterAnnotation?

Here my code:

func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
        clusteringManager.renderAnnotations(onMapView: mapView)
    }
    
    func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
        
        switch annotation {
        case let annotation as ClusterAnnotation:
            
            let id = ClusterAnnotationView.identifier
            var clusterView = mapView.dequeueReusableAnnotationView(withIdentifier: id)
            
            if clusterView == nil {
                clusterView = ClusterAnnotationView(annotation: annotation, reuseIdentifier: id)
            } else {
                clusterView?.annotation = annotation
            }
            return clusterView
            
        case let annotation as MKClusterAnnotation:
            
            let id = ClusterAnnotationView.identifier
            var clusterView = mapView.dequeueReusableAnnotationView(withIdentifier: id)
            
            if clusterView == nil {
                clusterView = ClusterAnnotationView(annotation: annotation, reuseIdentifier: id)
            } else {
                clusterView?.annotation = annotation
            }
            return clusterView
            
        case let annotation as ParkingMeterAnnotation:
            
            let id = ParkingMeterAnnotationView.reuseId
            var parkingMeterAnnotationView = mapView.dequeueReusableAnnotationView(withIdentifier: id)
            
            if parkingMeterAnnotationView == nil {
                parkingMeterAnnotationView = ParkingMeterAnnotationView(annotation: annotation, reuseIdentifier: id)
            } else {
                parkingMeterAnnotationView?.annotation = annotation
            }
            return parkingMeterAnnotationView
            
        default:
            // return annotation view
            SLog(message: "")
            return MKAnnotationView()
        }

Finally the error I receive is an exception, attached capture.

issue-pinfloyd

Thanks for your attention,

A greeting.

@jasanchezsa
Copy link
Author

Hello again,

Actually the error is here:

captura de pantalla 2019-02-11 a las 19 19 34

As you indicate in:

https://robots.thoughtbot.com/how-to-handle-large-amounts-of-data-on-maps#adding-only-the-annotations-we-need

Many thanks,

A greeting.

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

1 participant