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&v=2&key=' +
{
'example.com': 'api-key-for-example.com',
'anotherexample.com': 'api-key-for-anotherexample.com'
}[location.host] +
'" type="text/javascript"><\/script>' );
</script>