我使用的是Google地圖自動完成查詢,就像您在下面看到的一樣,我確定了我的位置周圍的自動完成的邊界,但我仍然得到距離我的位置很遠的地方。我也檢查了邊界,西南邊界,東南邊界,他們也是如此,但是這裏的地方並不是這樣。Google Swift自動完成查詢
var northRegion = CLLocationCoordinate2DMake((locationManager.location?.coordinate.latitude)!*1.0001, (locationManager.location?.coordinate.longitude)!*1.01)
var southRegion = CLLocationCoordinate2DMake((locationManager.location?.coordinate.latitude)!*0.99, (locationManager.location?.coordinate.longitude)!*0.9999)
var bounds = GMSCoordinateBounds(coordinate: northRegion, coordinate: southRegion)
print(locationManager.location?.coordinate.latitude)
print(locationManager.location?.coordinate.longitude)
print(bounds.northEast)
print(bounds.southWest)
var filter = GMSAutocompleteFilter()
filter.type = GMSPlacesAutocompleteTypeFilter.Geocode
var yourLat = locationManager.location?.coordinate.latitude
var yourLon = locationManager.location?.coordinate.longitude
placesClient = GMSPlacesClient()
placesClient?.autocompleteQuery("cape", bounds: bounds, filter: filter, callback: { (result, error) -> Void in
for item in result! {
print(item.attributedFullText)
}
})
例如,我的位置是伊斯坦布爾,當我寫這個,我得到了開普敦的數據。