Here's a small problem..
I've done some code which should change the image of the pin that get's dropped in mapView. The url of "taxi.png" works on an image view so that's not the current problem.
I also tried:
pinView?.image = UIImage(named: "taxi.png")
Code:
if pinView == nil{
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView?.canShowCallout = true
var imageTaxi = UIImage(named: "taxi.png")!
imageTaxi = imageTaxi.withAlignmentRectInsets(UIEdgeInsetsMake(0, 0, imageTaxi.size.height/2, 0))
pinView?.image = imageTaxi
}
let button = UIButton(type: .detailDisclosure)
pinView?.rightCalloutAccessoryView = button
return pinView
Does anybody see what should be fixed here to view the image?
EDIT: I now have this and I still have the standard red pinpoint..
let annotation = CustomPin()
annotation.coordinate = location
annotation.title = "Boek Taxi"
annotation.subtitle = ""
let image = UIImage(named: "taxi.png")
annotation.Image = image
self.mapView.addAnnotation(annotation)
let reuseId = "pin"
var pinView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseId)
if pinView == nil{
pinView = MKPinAnnotationView(annotation: CustomPin() as MKAnnotation, reuseIdentifier: reuseId)
pinView?.canShowCallout = true
} else {
pinView?.annotation = CustomPin() as MKAnnotation
}
let cpa = annotation as! CustomPin
pinView?.image = cpa.Image
let button = UIButton(type: .detailDisclosure)
pinView?.rightCalloutAccessoryView = button
return pinView
}
Any things I've over looked?