Reputation: 81
I've been trying this for a while and there is never a response back from Google. PlaceID is found using GMS Autocomplete. Code is pretty much copied and pasted from https://developers.google.com/maps/documentation/places/ios-sdk/place-details#get-place Anyone have any ideas?
let placeID = placeIdString
// Specify the place data types to return.
let fields: GMSPlaceField = GMSPlaceField(rawValue: UInt(GMSPlaceField.name.rawValue) | UInt(GMSPlaceField.coordinate.rawValue) |
UInt(GMSPlaceField.placeID.rawValue))
placesClient?.fetchPlace(fromPlaceID: placeID, placeFields: fields, sessionToken: nil, callback: {
(place: GMSPlace?, error: Error?) in
print("bueller?")
if let error = error {
print("An error occurred: \(error.localizedDescription)")
completion(nil)
}
if let place = place {
//self.lblName?.text = place.name
print("The selected coord is: \(place.name ?? "nada") \(place.coordinate.latitude) \(place.coordinate.longitude)")
//coordFound = place.coordinate
completion(place.coordinate)
}
})
Upvotes: 0
Views: 249
Reputation: 11
try to use shared instance for places client:
private var placesClient = GMSPlacesClient.shared()
Upvotes: 1