@IBOutlet weak var map: MKMapView!
override func viewDidLoad() {
map.delegate = self
showAlarms()
super.viewDidLoad()
// Do any additional setup after loading the view.
}
func showAlarms(){
map.region.center.latitude = 10.733051
map.region.center.longitude = 76.763042
map.region.span.latitudeDelta = 1
map.region.span.longitudeDelta = 1
}
func mapView(mapView: MKMapView!,
viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
if annotation is MKUserLocation {
//return nil so map view draws "blue dot" for standard user location
return nil
}
let reuseId = "pin"
var pinView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseId) as? MKPinAnnotationView
if pinView == nil {
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView!.canShowCallout = true
//pinView!.animatesDrop = true
pinView!.image = UIImage(named:"annotation")!
}
else {
pinView!.annotation = annotation
}
return pinView
}
I need to show to a custom pin image for my mapview in swift ios. The custom image is not loading neither the pin. I have an image named "annotation" which I need to load in my mapview.