2
votes

Is there a way to batch multiple reverse-geocoding requests on the Google Maps API?

I only see simple requests possible: https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY

1
I do believe so but what do you mean exactly? you can do 50 requests per second, calculated as the sum of client-side and server-side queries as stated in the documentationbetofarina

1 Answers

5
votes

Google Geocoding Api Web Service

No, it doesn't let you, as you already noticed, to add multiple addresses, because the required parameter is not an array as stated by documentation:

Required parameters in a reverse geocoding request: latlng — The latitude and longitude values specifying the location for which you wish to obtain the closest, human-readable address.

You didn't specify the code context that you are using. Can I suggest you to implement another Google Api? It will be a lot easier to do multiple request via code.

Google Geocoding Javascript Api

With this Api you can do multiple requests like this:

 var locations = [
      { lat: -31.563910, lng: 147.154312 },
      { lat: -33.718234, lng: 150.363181 },
      { lat: -33.727111, lng: 150.371124 },
      { lat: -33.848588, lng: 151.209834 }
];

var geocoder = new google.maps.Geocoder();

for (i = 0; i < locations.length; i++) {
  geocodeAddress(locations[i]);
}

Full example here and documentation example here