Thursday, October 2, 2008

Experimenting Google Maps with Local Files

I found one link, and I just quote it from http://cafe.elharo.com/web/google-maps-tip-1-experimenting-with-local-files/:

As you probably know using Google maps on a web site requires a custom API key that is locked to the web site. For example, my key is ABQIAAAANzhjmjn_aQro8IDfoVHCkxT-n61mIiazNPHwWTk3s75Ar5J1YhQDxyPhUR-O4Nfg_1iRn1pAUseY4g and every page that uses a Google map includes this script element:

<script src="http://maps.google.com/maps?file=api&v=1&key=ABQIAAAANzhjmjn_aQro8IDfoVHCkxT-n61mIiazNPHwWTk3s75Ar5J1YhQDxyPhUR-O4Nfg_1iRn1pAUseY4g" type="text/javascript"></script>

I’m not giving away any secret by telling you that. You could figure out the same thing using View Source. However. the key is locked to the web site. If you try using that key on a different site, the map won’t load.

This is all well and good. However it’s very inconvenient for debugging, testing, and experimenting, because you can’t load a map on your local file system. Everything has to be tested on the live Web server. You could probably password proterct a directory to play around in, but what a pain.

It turns out that you can use this script element on your local hard drive:

<script src="http://maps.google.com/maps?file=js" type="text/javascript"></script>

Then you can test out and play with Google Maps without loading the file onto the production web server first. Cool!

Subscribe in a Reader