Google Maps integration via jQuery

By gadefgaertgqe - November 23, 2010 - edited: November 23, 2010

Well I tried everything but no luck.

I removed any PHP just in case and worked with the rendered PHP output.

I checked for any odd formatting or characters in the pre-rendered PHP output of which I found none.

I tried each marker info on it's own, and discovered that the first one is always ignored but again I have no idea why. So I worked round that with dummy marker info at the start. Everything checked out fine.

I also modded the gMap javascript so that there was a delay in processing each marker. That did nothing other than make me wait longer for the test to run lol. I'll say that my javascript knowledge is poor so I was shooting blind.

I ran the gMap script though all versions of jQuery from 1.3 through to 1.4.4, all of which gave me the same fail result.

A search on google for the same problem produced no results.

All I can think of is that somehow the javascript loop that places the markers seems to be out of sync. This would explain why:

A: Markers are random
B: The number of markers shown is roughly the same but does vary. In my case the number of markers is generally no more than 19 (although once it did show a few more). Sometimes it can be as little as 9. It should show 57.

Is it even possible for java to be 'out of sync'?

This is an area I will explore tomorrow.

I also looked for other scripts to do what we need, and to be honest we choose gMap for good reason ;) Looks like I may have to get my hands dirty with the Google Maps V3 API . . . which I loath! lol.

Paul

Re: [Pixels & Beats] Google Maps integration via jQuery

By Chris - November 23, 2010

I did a little digging. It's the Geocoder.

gMap is using the Google Geocoding API to resolve addresses and Google's service isn't returning valid positions for all the addresses requested, (only the first few.) gMap doesn't have any error checking to make sure a proper position was returned.

Google says:

"As a general best practice, it is not recommended to use GClientGeocoder functions in a loop. Developers that have multiple addresses to geocode should probably use our HTTP Geocoder instead."

gMap is using the GClientGeocoder functions in a loop.

Also, Google says of their Geocoding API:

"Use of the Google Geocoding API is subject to a query limit of 2,500 geolocation requests per day. (User of Google Maps API Premier may perform up to 100,000 requests per day.) This limit is enforced to prevent abuse and/or repurposing of the Geocoding API, and this limit may be changed in the future without notice. Additionally, we enforce a request rate limit to prevent abuse of the service."

I'm pretty sure that's what's happening: gMap is making too many requests in too short of a time and Google's geocoding service starts failing.

I think the simplest solution is to geocode addresses on the server-side. Your markers will display immediately and you won't have to worry about query limits. We have a plugin in development which does exactly that. I'm going to finish it up and release it as soon as possible — hopefully tomorrow! I'll post here when it's ready.

P.S. The good news is that you should be able to keep using gMap. :)
All the best,
Chris

Re: [chris] Google Maps integration via jQuery

By Toledoh - November 23, 2010

Chris - you're a champion! Thanks!
Cheers,

Tim (toledoh.com.au)

By gadefgaertgqe - November 24, 2010

WoW! You are like the Cavalry charging in just when we thought it was all over ;)

I am waiting to go ahead with my first stage of the go live on the website so this is fantastic news. I'll stay tuned!

Paul

Re: [Pixels & Beats] Google Maps integration via jQuery

By gadefgaertgqe - November 29, 2010

I really don't want to sound like I am hounding you Chris . . . . . . but any idea when the plugin may be released? [;)]

I am happy to beta test. Especially when my MD is asking when the site is going live lol.

Kind Regards

Paul

Re: [Pixels & Beats] Google Maps integration via jQuery

By Toledoh - November 29, 2010

Hi Chris,

You are right... changing the fields to lat/long works a treat!
Cheers,

Tim (toledoh.com.au)

By Chris - November 29, 2010

Hi folks,

We've just released our Geocoder plugin, which has been in development for a while now! It'll automatically get lat/lng coordinates for you.

More information on the plugin is available here:

http://www.interactivetools.com/forum/gforum.cgi?post=84902

Please let me know if you have any questions.
All the best,
Chris