I'm using a simple marker cluster taken from here https://github.com/ribl/FBAnnotationClusteringSwift
and I see this part of code responsible for putting on the map either a cluster or a pin:
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
var reuseId = ""
if annotation.isKindOfClass(FBAnnotationCluster) {
reuseId = "Cluster"
var clusterView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
clusterView = FBAnnotationClusterView(annotation: annotation, reuseIdentifier: reuseId, options: nil)
return clusterView
} else {
reuseId = "Pin"
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView!.pinColor = .Green
return pinView
}
}
It works fine, I see the clusters or single pins, but now I want to add a popup for every pin that user presses, something like presented here:
I found this screenshot here http://www.raywenderlich.com/90971/introduction-mapkit-swift-tutorial
and following this tutorial I created a class SingleRequest
and also modified the mentioned above code, so now it looks like this:
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
var reuseId = ""
if annotation.isKindOfClass(FBAnnotationCluster) {
reuseId = "Cluster"
var clusterView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
clusterView = FBAnnotationClusterView(annotation: annotation, reuseIdentifier: reuseId, options: nil)
return clusterView
} else {
reuseId = "Pin"
if let annotation = annotation as? SingleRequest {
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView!.pinColor = .Green
pinView!.canShowCallout = true
pinView!.calloutOffset = CGPoint(x: -5, y: 5)
pinView!.rightCalloutAccessoryView = UIButton(type: .DetailDisclosure) as UIView
return pinView
}
return nil
}
}
But still, there is nothing visible when I click the pin on the map. What is more, the single pins are now red (default color), so seems like this line:
pinView!.pinColor = .Green
is ignored in the code, probably the rest too.
What am I missing here?