I have implemented google place autocomplete api and I have applied bounds to restrict my auto complete search to one specific city Orlando, FL, USA but Google place api is not filtering data for only this city. It is searching placing all over USA and other cities name outside USA. I want google autocomplete api to return only this city addresses. Here is the code for same:
let placesClient = GMSPlacesClient()
let searchBound = getCoordinateBounds(latitude: CLLocationDegrees(28.5383), longitude: CLLocationDegrees(81.3792), distance: 1.45)
let filter = GMSAutocompleteFilter()
filter.country = "USA"
placesClient.autocompleteQuery(text!, bounds: searchBound, filter: filter, callback: { (results, error) in
})
//My getCoordinateBounds method
func getCoordinateBounds(latitude:CLLocationDegrees ,
longitude:CLLocationDegrees,
distance:Double = 0.001)->GMSCoordinateBounds{
let center = CLLocationCoordinate2D(latitude: latitude,
longitude: longitude)
let northEast = CLLocationCoordinate2D(latitude: center.latitude + distance, longitude: center.longitude + distance)
let southWest = CLLocationCoordinate2D(latitude: center.latitude - distance, longitude: center.longitude - distance)
return GMSCoordinateBounds(coordinate: northEast,
coordinate: southWest)
}
Note: I want to filter addresses those are around 100 miles radius of this latitude and longitude (that why I have given degree to 1.45). Another thing I added country filer USA after I found that my bounds filter is not working properly. So far I am able to restrict address search to USA.