I have added the following code and not able to see any pin changes with new image and no error is getting displayed. map.delegate = self is done. do we need to add any code to make it work? any help?
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let userLocation:CLLocation = locations[0] as CLLocation
let span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, longDelta)
let region:MKCoordinateRegion = MKCoordinateRegionMake(userLocation.coordinate, span)
routeMapView.setRegion(region, animated: true)
currentLocationAnnotation.coordinate = userLocation.coordinate
mapView(routeMapView, viewForAnnotation: currentLocationAnnotation)!.annotation = currentLocationAnnotation
routeMapView.addAnnotation(currentLocationAnnotation)
//print("getting current location..")
getCurrentLocationAddress(userLocation)
userCurrentLocation = userLocation
userLocationSpan = span
counter++
}
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.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView
if pinView == nil {
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView!.canShowCallout = true
pinView!.animatesDrop = true
pinView!.image = UIImage(named:"first")!
print(pinView!.image!)
routeMapView.delegate = self
}
else {
pinView!.annotation = annotation
}
return pinView
}