In adding marker when user touch the map, use didTapAtCoordinate
this was called after a tap gesture at a particular coordinate, but only if a marker was not tapped. Or, didLongPressAtCoordinate
when long press gesture at a particular coordinate.
To add a marker, you need to create a GMSMarker
object that includes a position
and title
and set its map
.
The following example demonstrates how to add a marker to an existing GMSMapView object. The marker is created at coordinates 10,10, and displays the string "Hello world" in an info window when clicked.
let position = CLLocationCoordinate2DMake(10, 10)
let marker = GMSMarker(position: position)
marker.title = "Hello World"
marker.map = mapView
Here's a related SO ticket, discuss regarding touch event: Google Maps iOS SDK Touch Events