I’m trying to implement the GoogleMapAPI class and having some odd results.
On my local dev machine (where I’ve set up a Google API key, but it still won’t work so I can’t test from) when I use the method getGeocode and pass a variable holding an address, it returns the lat/long coordinate values just fine.
However, when I upload and use on a live production server, the method fails and returns nothing.
Any ideas what could be happening?
Thanks for any help.
Also, any reason why my local Google API key doesn’t work? Thanks.
That code depends on the now deprecated Gmaps Version 2 (v2).
The latest is v3, and no longer requires a key (big win!). Though check the browser support list.
Using v2 though, you need to keep 2 keys, the official one you get from Google for your account tied to your URL and the special “localhost” key, which you get from the API docs somewhere. Try:
Then you have the pain of either detecting which computer is serving the files and loading the correct key, or change it manually whenever you FTP your files to the server.
What a PITA.
That is one good reason to upgrade to v3 and just learn to use the API yourself, IMO.
If you are up for it then heres my guide to essential Gmaps v3 Gotchas.
I’ve never used that particular service but most others that I have used require a separate credentials be registered per domain. So you could register for a separate API key for your production environment and see if that fixes the issue. You should also be able to further analyze the problem by looking at the error, exception, fault the service provides as feedback for origins of the problem. Again this is only speculation based on the services I have used in the past.