Reputation: 4726
I'm using Google Maps SDK for an iOS application of mine.
I configured it so that when a tap occurs on a GMSMarker
, it shows it's title. It's working alright.
I want to do the same for GMSPolyline
s but couldn't figure out how. The lines's tappable
property is set to true
.
How can I achieve this. Thanks.
P.S. coding with Swift 2.0
Upvotes: 2
Views: 929
Reputation: 1192
Conform to the protocol GMSMapViewDelegate
:
class ViewController: UIViewController, GMSMapViewDelegate {
...
}
Set the ViewController
to be the delegate of your map view:
override func viewDidLoad() {
...
viewMap.delegate = self
}
Use the method mapView:didTapOverlay:
func mapView(mapView: GMSMapView, didTapOverlay overlay: GMSOverlay) {
print(overlay.title)
}
This method is called whenever a tap is detected inside the map view.
For more information: GMSOverlay
Upvotes: 3