Geocoding markers shows error when creating 11 or more

890 views
Skip to first unread message

moderntymes

unread,
Jul 13, 2010, 8:43:15 AM7/13/10
to Google Maps JavaScript API v3
I'm trying to create a map with approximately 40 markers. Each marker
is geocoded and has an event handler for 'clicked' that redirects to a
new page. I've pretty much used the geocoding code straight from the
Google API v3 site, but the code fails if I add more than 10 markers.
On the 11th, I get a Javascript error. If I try to show more than 11,
then all the markers disappear.

I receive a rather useless (to me at least) error message: '0' is null
or not an object.

If I take out the event handler, the problem remains so it seems to be
connected to the geocoding. I think it has something to do with these
lines:
geocoder13.geocode( { 'address': '6059 S Seneca,Wichita,KS,67217'},
function(results, status) {
var marker13 = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
title:"Cox Farm"
});
});

In particular, if I remove the stuff after function(results, status)
{ up to the next }, I don't get an error. Of course I also don't get
any markers!

I tried with each geocoding occurence listed separately, which you can
see here: http://cornmaze.moderntymes.com/map.htm

I also tried making a function to do the geocoding here:
http://cornmaze.moderntymes.com/map_testgc.htm

Results are the same either way.

geoco...@gmail.com

unread,
Jul 13, 2010, 9:19:30 AM7/13/10
to Google Maps JavaScript API v3
The general advice is not to geocode addresses everytime your page
loads. Geocode them once, offline, then use the resulting coordinates
to display the markers.

Geocoding the addresses every time wastes google's resources, so they
have implemented rate limits and quotas. You should only geocode
addresses you don't know in advance (like user input) on the fly.

-- Larry

moderntymes

unread,
Jul 13, 2010, 9:46:16 AM7/13/10
to Google Maps JavaScript API v3
Certainly that's good advice, but these locations are actually dynamic
(or will be in the final version). The locations will be coming from a
frequently changing database, so I'll need to be doing the geocoding.

I think there's a problem with the programming though, and I think it
is related to the Javascript closure.

On Jul 13, 9:19 am, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
>   -- Larry- Hide quoted text -
>
> - Show quoted text -

geoco...@gmail.com

unread,
Jul 13, 2010, 10:27:02 AM7/13/10
to Google Maps JavaScript API v3
On Jul 13, 6:46 am, moderntymes <doug-goo...@moderntymes.com> wrote:
> Certainly that's good advice, but these locations are actually dynamic
> (or will be in the final version). The locations will be coming from a
> frequently changing database, so I'll need to be doing the geocoding.
>
> I think there's a problem with the programming though, and I think it
> is related to the Javascript closure.

Sounds to me like you need to implement your code to handle error
conditions better.

-- Larry
> > - Show quoted text -- Hide quoted text -

geoco...@gmail.com

unread,
Jul 13, 2010, 10:48:31 AM7/13/10
to Google Maps JavaScript API v3
On Jul 13, 7:27 am, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Jul 13, 6:46 am, moderntymes <doug-goo...@moderntymes.com> wrote:
>
> > Certainly that's good advice, but these locations are actually dynamic
> > (or will be in the final version). The locations will be coming from a
> > frequently changing database, so I'll need to be doing the geocoding.
>
> > I think there's a problem with the programming though, and I think it
> > is related to the Javascript closure.
>
> Sounds to me like you need to implement your code to handle error
> conditions better.

and add a createMarker function so you get function closure:
http://www.geocodezip.com/cornmaze_moderntymes_com_map_testgcA.html

Note that even with those few locations I get an OVER_QUERY_LIMIT
error for one of those points.
You will need to rethink your design.

moderntymes

unread,
Jul 13, 2010, 11:30:02 AM7/13/10
to Google Maps JavaScript API v3
I have no idea why there would be OVER_QUERY_LIMIT error, but isn't
that on a per client basis anyway? I certainly haven't made 2500
geolocation requests today. That seems very odd.

I tried to keep the code design as simple as possible. I will try
creating a createMarker function to get function closure, which could
very well be my problem. I understand I need to "rethink my design",
which is why I was posting here.The createMarker function will
hopefully help, and thanks for the code sample!

On Jul 13, 10:48 am, "geocode...@gmail.com" <geocode...@gmail.com>

Rossko

unread,
Jul 13, 2010, 11:50:43 AM7/13/10
to Google Maps JavaScript API v3
> I have no idea why there would be OVER_QUERY_LIMIT error, but isn't
> that on a per client basis anyway? I certainly haven't made 2500
> geolocation requests today. That seems very odd.

Not odd at all. 2500/day is one every 35 seconds. Google do allow
you to have small bursts, but they do also apply a rate limit which
your method is clearly breaking. You need to throttle your
requests. Your map is going to load very slowly if you geocode every
time someone views it.

Geocode your data at point of entry to the database ; it matters not
if it changes daily. Not only does it prevent your application from
hogging resources shared by other people, but your own map will
perform many times faster.

moderntymes

unread,
Jul 13, 2010, 6:44:03 PM7/13/10
to Google Maps JavaScript API v3
If there is throttling, which would certainly explain this, Google
should really say so in their API. If it weren't for their rate
limiting, seems like it would load plenty fast since the 10 that work
ok come up quite fast. Forty doesn't seem like so many to me,
considering I've seen examples where there are 100s or even thousands
of markers. I understand they must not be geolocating for those, but
still...

I read and re-read the section in the API regarding geolocation (again
just now) and didn't see anything about a rate limit, other than the
2500/day limit. I appreciate your info and quick responses, to make up
for what the online references lacked!

geoco...@gmail.com

unread,
Jul 13, 2010, 10:08:47 PM7/13/10
to Google Maps JavaScript API v3
On Jul 13, 3:44 pm, moderntymes <doug-goo...@moderntymes.com> wrote:
> If there is throttling, which would certainly explain this, Google
> should really say so in their API. If it weren't for their rate
> limiting, seems like it would load plenty fast since the 10 that work
> ok come up quite fast. Forty doesn't seem like so many to me,
> considering I've seen examples where there are 100s or even thousands
> of markers. I understand they must not be geolocating for those, but
> still...
They aren't geocoding, they are using latitude and longitude directly
without using any additional resources from google other than the API
javascript and the map tiles.

Geocoding is a shared "free" resource. You are trying to hog it. The
rate limit prevents people from doing that.

-- Larry

>
> I read and re-read the section in the API regarding geolocation (again
> just now) and didn't see anything about a rate limit, other than the
> 2500/day limit. I appreciate your info and quick responses, to make up
for what the online references lacked!
>
> On Jul 13, 11:50 am, Rossko <ros...@culzean.clara.co.uk> wrote:
>
>
>
> > > I have no idea why there would be OVER_QUERY_LIMIT error, but isn't
> > > that on a per client basis anyway? I certainly haven't made 2500
> > > geolocation requests today. That seems very odd.
>
> > Not odd at all.  2500/day is one every 35 seconds.   Google do allow
> > you to have small bursts, but they do also apply a rate limit which
> > your method is clearly breaking.   You need to throttle your
> > requests.   Your map is going to load very slowly if you geocode every
> > time someone views it.
>
> > Geocode your data at point of entry to the database ; it matters not
> > if it changes daily.  Not only does it prevent your application from
> > hogging resources shared by other people, but your own map will
> > perform many times faster.- Hide quoted text -

Rossko

unread,
Jul 14, 2010, 4:29:50 AM7/14/10
to Google Maps JavaScript API v3
> I read and re-read the section in the API regarding geolocation (again
> just now) and didn't see anything about a rate limit, other than the
> 2500/day limit.

What it does say is
"The Google Maps API provides a geocoder class for geocoding addresses
dynamically from user input."
They're not expecting users to type so fast.
Reply all
Reply to author
Forward
0 new messages