Developping with googleMaps everywhere with the same licence id

When you want to use google maps on a website, you need to signup and get a key for the internet domain name that will use google Maps.

When your developing your googleMaps feature, it's not on the production site with the final url. (At least... I hope it's not so ;)
And you may code some google feature for several sites, and all these sites, you often code it on your computer with a local Apache/Php or Tomcat server.

So in you html (jsp, php, asp whatever) page you'll include the following code to have access to the google maps feature.


<!-- google map -->
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=A...5g"> </script>


A simple trick, is to request a key for a fake domain here : http://code.google.com/apis/maps/signup.html

Let's say, for "http://toms-projects"

Get the key, put it in your html code, and then edit your etc/hosts file.
(/etc/hosts on linux, c:\windows\system32\drivers\etc\hosts)

and edit the 127.0.0.1 line to

127.0.0.1       localhost toms-projects


As all system, by default, query the /etc/hosts file before making a DNS query,

toms-projects will be located at 127.0.0.1 by the machine dns client, and thus point to your local website.

And google sees the api key used for the toms-projects domain.

And everything works.

Even better,

you may register directly the final domain key, let's say http://mysupersite.com

and edit you /etc/hosts in the same way :

127.0.0.1       localhost mysupersite.com


It will work as well, but beware, as long as you /etc/hosts file will be configured that way, mysupersite.com will be your computer !

Comments

Popular posts from this blog

Upgrade Slimframework v3 to v4, how I did it

Reset Bacula database and files

Limit the upload bandwidth of your apache webserver with mod_bw