2
@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
}
我需要在swift ios中顯示我的mapview的自定義圖釘圖像。自定義圖像不會加載該引腳。我有一個名爲「註釋」的圖像,我需要在我的mapview中加載。如何在Mapview swift ios中設置自定義圖釘圖像?
viewForAnnotation的委託方法是否爲您調用。 –
@KiritModi。我不這麼認爲。它只顯示地圖,沒有別的。請幫忙。 – Rakesh
你是swift 3中的代碼 –