I want to create a info window for a Google map marker to provide a button click event inside the info window in my iOS application. Is there any way to do this?
Asked
Active
Viewed 1,285 times
1
-
I found this video from 2013, hope this can help you: https://www.youtube.com/watch?v=ILiBXYscsyY – Hieu Dinh Aug 03 '16 at 08:19
-
and another topic on stackoverflow: http://stackoverflow.com/questions/16746765/custom-info-window-for-google-maps – Hieu Dinh Aug 03 '16 at 08:20
1 Answers
0
Hope this can help you
extension ViewController: MKMapViewDelegate {
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation {
return nil
}
let identifier = "MyCustomAnnotation"
var annotationView = mapView.dequeueReusableAnnotationViewWithIdentifier(identifier)
if annotationView == nil {
annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
annotationView?.canShowCallout = true
} else {
annotationView!.annotation = annotation
}
let myButton = UIButton()
annotationView?.leftCalloutAccessoryView = myButton
return annotationView
}
}

Hieu Dinh
- 692
- 5
- 18