GMSPlace returns invalid coordinate (-180, -180), but name and place ID are correct
I was facing the same issue and went through the Place SDK documentation which says clearly that we should define before hand to the GMSPlaceField of what details do we need exactly and if you had followed the doc completely, it would be resulting only in the name and placeId being populated.
So while instantiating your GMSAutoCompleteViewController define in the following way.
**let fields: GMSPlaceField = GMSPlaceField(rawValue:UInt(GMSPlaceField.name.rawValue) |
UInt(GMSPlaceField.placeID.rawValue) |
UInt(GMSPlaceField.coordinate.rawValue) |
GMSPlaceField.addressComponents.rawValue |
GMSPlaceField.formattedAddress.rawValue)!
autocompleteController.placeFields = fields**
Swift : Using Google Places with iOS and getting -180 as Latitude
I found it.
Where you present GMSAutocompleteViewController
, you can add GMSPlaceField
field to specify what data you want, like this:
@objc func autocompleteClicked(_ sender: UIButton) {
let autocompleteController = GMSAutocompleteViewController()
autocompleteController.delegate = self
// Specify the place data types to return.
let fields: GMSPlaceField = GMSPlaceField(rawValue:UInt(GMSPlaceField.name.rawValue) |
UInt(GMSPlaceField.placeID.rawValue) |
UInt(GMSPlaceField.coordinate.rawValue) |
GMSPlaceField.addressComponents.rawValue |
GMSPlaceField.formattedAddress.rawValue)!
autocompleteController.placeFields = fields
// Specify a filter.
let filter = GMSAutocompleteFilter()
filter.type = .noFilter
autocompleteController.autocompleteFilter = filter
// Display the autocomplete view controller.
present(autocompleteController, animated: true, completion: nil)
}
I got this function from https://developers.google.com/places/ios-sdk/autocomplete
Related Topics
Saving Exif Data to Jpeg - Swift
Swift Probability of Random Number Being Selected
Swift Threading with Dispatchgroup
Xcode Swift. How to Programmatically Select Cell in View-Based Nstableview
Uicollectionview Scrolltoitematindexpath, Not Loading Visible Cells Until Animation Complete
Protocol Having Generic Function and Associatedtype
Swift Build Error_If_Any_Output_Files_Are_Specified_They_All_Must_Be
(Appkit) Tab Insertion Inside of Nstextblock
How to Save Value in Nsset Core Data (Swift)
Swiftui: Two-Finger Swipe ( Scroll ) Gesture
Using Animoji/Memoji as Profile Photo
Add Datepicker in Uiactionsheet Using Swift
Combined Chart (Line- and Bar Chart) Using iOS-Charts
Loop Over Multiple Uialertcontroller'S
How to Define an Extension to Collectiontype So That Its Methods Are Available to Dictionaries
How to Duplicate a Sprite in Sprite Kit and Have Them Behave Differently