This has been function in my application for quite a while and only stopped working recently.
func reverseGeocodeCoordinate(coordinate: CLLocationCoordinate2D, onSuccess : @escaping LocationUpdateSuccess) {
let geocoder = GMSGeocoder()
geocoder.reverseGeocodeCoordinate(coordinate) { response, error in
if let address = response?.firstResult() {
if let lines = address.lines! as? [String] {
let title = lines.joined(separator: " ")
if (title.characters.count) > 3 {
print(title)
onSuccess(coordinate, title)
}
}
}
else
{
print("Error In Reverse GeoCoding \n \(error?.localizedDescription)")
}
}
}
For what it's worth, Here's what I'm sending as the parameter values
CLLocationCoordinate2D
- latitude : 31.51774603759463
- longitude : 74.340778893683378
Here's the exact text of the error when I make the request
The operation couldn’t be completed. (com.google.HTTPStatus error 400.)
Similarly
GMSPlacesClient().autocompleteQuery
wouldn't respond with results as it used to in the following function
func autoCompleteQuery(searchText: String) {
if searchText.characters.count != 0 {
self.tableView.alpha = 1
let countryFilter = GMSAutocompleteFilter()
countryFilter.country = "US"
var areaBounds : GMSCoordinateBounds? = nil
if let lastSavedLocation = MyLocationManager.sharedInstance.lastSavedLocation
{
let lat = lastSavedLocation.coordinate.latitude
let long = lastSavedLocation.coordinate.longitude
let offset = 200.0 / 1000.0;
let latMax = lat + offset;
let latMin = lat - offset;
let lngOffset = offset * cos(lat * M_PI / 200.0);
let lngMax = long + lngOffset;
let lngMin = long - lngOffset;
let initialLocation = CLLocationCoordinate2D(latitude: latMax, longitude: lngMax)
let otherLocation = CLLocationCoordinate2D(latitude: latMin, longitude: lngMin)
areaBounds = GMSCoordinateBounds(coordinate: initialLocation, coordinate: otherLocation)
}
placesClient.autocompleteQuery(searchText, bounds: areaBounds, filter: countryFilter, callback: { (result, error) -> Void in
self.nearbyPlacesList.removeAll()
if result == nil {
print("Error in autocompleteQuery -> \(error?.localizedDescription)")
return
}
for result in result!{
if let result = result as? GMSAutocompletePrediction {
self.nearbyPlacesList.append((id: result.placeID!, name: result.attributedFullText.string))
self.tableView.reloadData()
}
}
})
} else {
self.tableView.alpha = 0
}
}
with the following error message.
The operation couldn’t be completed. An internal error occurred in the Places API library. If you believe this error represents a bug, please file a report using the instructions on our community and support page (https://developers.google.com/places/ios-api/support).
I've looked into answers here, reinstalling the pods and what not.
I also matched the bundle identifier, lifted restrictions on API quotas, disabled and enabled the SDKs again from Google's Cloud console as shown below
but nothing worked. Any help would be greatly appreciated. Thanks