MapsApi - Google maps is hosting service giving strange error
Google maps service does not work as expected and gives the following error
Unacceptable error: valid range. A possible reason is that the value conflicts with other properties.
Code
var service = new google.maps.places.PlacesService(map);
var request = {
location: centerLatLong,
rankBy: google.maps.places.RankBy.DISTANCE,
radius: 500
};
service.nearbySearch(request, function(results, status){
if (status == google.maps.places.PlacesServiceStatus.OK){
console.log(results)
}
});
source to share
radius
-property is not supported when used rankBy:distance
.
The documentation for the Javascript-API seems incomplete as it does not provide information that the radius-property is not allowed when used rankBy:distance
, but the documentation for the places-Webservice contains the following information:
radius
- defines the distance (in meters) within which the Results should be returned. The maximum radius allowed is 50,000 meters. Note that radius should not be included if rankby = distance (described in the Optional Parameters section below).
https://developers.google.com/places/webservice/search#PlaceSearchRequests
Solution: remove radius
-property
source to share