Right now my app has multiple markers on different locations. If you tap on a marker, there is a small window popping out including a title and a snippet. I would like to implement a button in the window, or make the info window tappable, so it works as a button to execute a function. So I wrote this block in my GoogleMapsViewController.swift:
func mapView(mapView: GMSMapView, didTapInfoWindowOfMarker marker: GMSMarker) {
print("test")
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("jobDetailVC") as! JobDetailViewController
if let value = marker.userData as? PFObject {
vc.name = value.objectForKey("name") as? String
vc.descriptionF = value.objectForKey("description") as? String
vc.price = value.objectForKey("price") as? Double
vc.objectId = value.objectId!
}
}
The reason why I am using: didTapInfoWindowOfMarker is because I wasn't sure how to implement it, so I read the docu from Google Maps: https://developers.google.com/maps/documentation/ios-sdk/reference/protocol_g_m_s_map_view_delegate-p?hl=es and thought that this was the best choice.
Has anyone successfully implemented this, or something similar? Thanks in advance for the help!