2

i have street addresses in the format of

1 Rue du Four, 60200 COMPIEGNE, France

2 Rue de Lancry, 60200 COMPIEGNE, France

And the list of address can be up to 100 000. hundred thousand.

currently i am using google gecode but it has limitations like per day 2500. i kept on getting this error.

google.maps.GeocoderStatus.OVER_QUERY_LIMIT

then i managed to do it with a timeout like below

function codeAddress(markersAddress) {

var address = markersAddress.address;
var name = markersAddress.name;
var info = markersAddress.info;
geocoder.geocode({'address': address}, function (results, status) {
  if (status == google.maps.GeocoderStatus.OK) {
    var latLng = results[0].geometry.location;
  } else {
    if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
      setTimeout(function() { codeAddress(markersAddress); }, (timeout * 3));
    } else {
      console.log('Geocode was not successful for the following reason: ' + status);
    }
  }
});

however this method is causing slowness in the browser when there is 100 000 records. so is there any better way to get geocode with a api ?

dev1234
  • 5,376
  • 15
  • 56
  • 115
  • 1
    100,000 records is the entirety of your problem. Reduce that number to something manageable, or [use your own database to cache results for a few days or weeks](http://leavesofcode.net/2013/05/07/caching-google-maps-geocoding-lookups/). – Blazemonger Dec 01 '15 at 14:41
  • 4
    Google's geocoding is pretty much the best there is. If you need to make more than 2,500 requests to it per day then you're going to have to use a paid service, no matter who you use. I would suggest looking in to getting a Google Maps Premier account if you really need to show 100,000 items on a map, although that should really never be the case. It would be worth implementing a filter of some kind to reduce that number. – Rory McCrossan Dec 01 '15 at 14:41
  • 1
    Possible duplicate of [How do I Geocode 20 addresses without receiving an OVER\_QUERY\_LIMIT response?](http://stackoverflow.com/questions/2419219/how-do-i-geocode-20-addresses-without-receiving-an-over-query-limit-response) – Victor Levin Dec 01 '15 at 14:41
  • 1
    you're fed up over a free service having limits? you should probably scale back your expectations, or pay for a service without the limits. – Marc B Dec 01 '15 at 14:41
  • Before committing to a design that embeds a service, i would encourage you to read the Terms Of Use ... not just scroll down and click the accept button. In fact, in this specific case, you probably should do just that (the read part). – YvesLeBorg Dec 01 '15 at 14:52
  • Geocode the addresses off-line and "cache" the results (for less than 30 days to comply with the [terms of service](https://developers.google.com/maps/terms#10-license-restrictions)), use the coordinates to display your markers. – geocodezip Dec 01 '15 at 15:03
  • @geocodezip is there any example of doing it offline? – dev1234 Dec 01 '15 at 15:05

1 Answers1

2

Geocode the addresses off-line and "cache" the results (for less than 30 days to comply with the terms of service), use the coordinates to display your markers.

More details: Geocoding Strategies article in the Google Maps Documentation.

geocodezip
  • 158,664
  • 13
  • 220
  • 245