-1

I wanna add marker in my app in google maps

I have this error

Use of unresolved identifier 'MapTasks'

enter image description here

var mapView: GMSMapView?
var locationManager = CLLocationManager()
var locationMarker: GMSMarker!
var mapTasks = MapTasks()  ---> error

all my problem is that I can't add optional marker when user touch in google maps.

Cœur
  • 37,241
  • 25
  • 195
  • 267
P.Tb
  • 99
  • 1
  • 5
  • 15

1 Answers1

-1

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

Community
  • 1
  • 1
Android Enthusiast
  • 4,826
  • 2
  • 15
  • 30