Problem
According to the official Google Maps Places API documentation, the radius
parameter is limited to 50,000 meters (50 km) for Autocomplete requests:
radius
The radius will automatically be clamped to a maximum value depending on the type of search and other parameters:
- Autocomplete: 50,000 meters [...]
However, in my tests, I'm getting results located more than 50 km away from the specified center, even when setting strictBounds=true
.
Code to Reproduce
@Test
void autocomplete_addresses_outside_50km_restriction() {
var dotenv = Dotenv.configure().filename("local.env").load();
var apiKey = dotenv.get("GOOGLE_API_KEY");
var context = new Builder().apiKey(apiKey).build();
// Center for the search
var center = new LatLng(43.93578243946096, 6.0261110523814);
var radiusInKm = 100; // Trying with 100km
var restriction = new LocationRestriction(center, radiusInKm);
var addresses = getAutocompleteAddress(context, "Jean Jaurès", restriction);
var distancesInKm = Arrays
.stream(addresses)
.map(prediction -> getPlaceDetails(context, prediction))
.map(placeDetail -> distanceInKms(center, toLatLng(placeDetail)))
.toList();
// Some results are beyond 50km
assertThat(distancesInKm).anyMatch(distanceInKm -> distanceInKm > 50);
}
You can find the complete test code in this GitHub repository: https://github.com/phdezann/google-maps-radius-restriction
Observed Behavior
My test passes, which means I'm receiving addresses that are more than 50 km away from the search center, while the documentation clearly states a 50 km limit.
Question
Is this behavior normal?