Welcome to Zooba Chat 2.0 Sign in | Join | Help

Zooba Chat

Anthony Main's random thoughts, theories and general whinges about all things and everything!
Google Maps on multidomains (alias')

Recently I've been embedding Google Maps onto various client websites for store locations etc and stumbled across the age old single API key issue. What am I talking about? Well Google only issues API keys for single domains, if you have a site which serves on multiple domains such as anthonymain.com and anthonymain.co.uk it would not work only on one. However I stumbled across the following code which seems to work a treat. I claim no responsibility for it so don't give me credit I'm just sharing the information from the following newsgroup thread. Original credits go to Mike Geary:

http://groups.google.com/group/Google-Maps-API/browse_thread/thread/c804b74034915665/
 

    <script type="text/javascript"> document.write(
      '<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=' +
      {
         'example.com': 'api-key-for-example.com',
         'anotherexample.com': 'api-key-for-anotherexample.com'
      }[location.host] +
      '" type="text/javascript"><\/script>' );
   </script>

 

 

Posted: Thursday, April 10, 2008 10:31 AM by Anthony

Comments

No Comments

Anonymous comments are disabled