I tried to get marker location from didTapAt but i do not get the place id Later i have to fetch place photos and place details. Is there any way to get the exact place id from google markers?
func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D) {
print("You tapped at \(coordinate.latitude), \(coordinate.longitude)")
mapView.camera = GMSCameraPosition.camera(withLatitude: coordinate.latitude, longitude: coordinate.longitude, zoom: 15)
}
var placesClient: GMSPlacesClient!
let fields: GMSPlaceField = GMSPlaceField(rawValue:UInt(GMSPlaceField.name.rawValue) |
UInt(GMSPlaceField.placeID.rawValue) |
UInt(GMSPlaceField.coordinate.rawValue) |
GMSPlaceField.addressComponents.rawValue |
GMSPlaceField.rating.rawValue |
GMSPlaceField.photos.rawValue |
GMSPlaceField.all.rawValue |
GMSPlaceField.formattedAddress.rawValue)!
placesClient?.fetchPlace(fromPlaceID: placeID, placeFields: fields, sessionToken: nil, callback: {
(place: GMSPlace?, error: Error?) in
if let error = error {
print("An error occurred: \(error.localizedDescription)")
self.stopActivityIndicator()
return
}
})
