views:

2872

answers:

4

Using the Google Geocoder v3, if I try to geocode 20 addresses, I get a OVER_QUERY_LIMIT unless I time them to be ~1 second apart, but then it takes 20 seconds before the markers are all placed.

Is there any other way to do it, other than storing the coordinates in advance?

+6  A: 

No, there is not really any other way : if you have many locations and want to display them on a map, the best solution is to :

  • fetch the latitude+longitude, using the geocoder, when a location is created
  • store those in your database, alongside the address
  • and use those stored latitude+longitude when you want to display the map.

This is, of course, considering that you have a lot less creation/modification of locations than you have consultations of locations.


Yes, it means you'll have to do a bit more work when saving the locations -- but it also means :

  • You'll be able to search by geographical coordinates
    • i.e. "I want a list of points that are near where I'm now"
  • Displaying the map will be a lot faster
    • Even with more than 20 locations on it
  • Oh, and, also (last but not least) : this will work ;-)
    • You will less likely hit the limit of X geocoder calls in N seconds.
    • And you will less likely hit the limit of Y geocoder calls per day.
Pascal MARTIN
I'm curious how you can be sure that the results are correct after some time has passed (let's say, a month). Do you re-query them every once in a while?
Chris
If the address *(that you already have in your DB -- else you wouldn't be able to geocode)* doesn't change, chances are pretty low that the latitude/longitude should change. And, of course, each time the address is modified, you should re-query the geocoder, to get the latitude+longitude that correspond to the new address.
Pascal MARTIN
+2  A: 

Unfortunately this is a restriction of the Google maps service.

I am currently working on an application using the geocoding feature, and I'm saving each unique address on a per-user basis. I generate the address information (city, street, state, etc) based on the information returned by Google maps, and then save the lat/long information in the database as well. This prevents you from having to re-code things, and gives you nicely formatted addresses.

Another reason you want to do this is because there is a daily limit on the number of addresses that can be geocoded from a particular IP address. You don't want your application to fail for a person for that reason.

Zachary
A: 

hy, I don't know how to do this. Please help me. I'm gonna be crazy. My problem : I want to reverse geocode some points with lat/lng. So I check in my database if I know the rev.geocoded address of this point, else I ask to google reverse geocoding service. then I save this address in my database for future use.

But, when I have more than 20 positions to rev. geocode, I've got the same message : Over_Query_Limit. Certainely because of request limitation per second. In fact, on client-side, after calling a WebService, I draw an html table in a div. For each cell of this table I check if I need to RG. If true, I call RG Service from my Google Map. Parameters for this function : this.RG(cell, lat, lng, callbackFct).

How to resolve my problem ?

PS: Sorry for my horrific english.

Please ask a new question on Stack Overflow if you need help with reverse geocoding.
michielvoo
A: 

I'm facing the same problem trying to geocode 140 addresses.

My workaround was adding usleep(100000) for each loop of next geocoding request. If status of the request is OVER_QUERY_LIMIT, the usleep is increased by 50000 and request is repeated, and so on.

And of cause all received data (lat/long) are stored in XML file not to run request every time the page is loading.

gray