«

»

Sep 19

Using Google Map API keys with Alternate Access Mapping.

On a clients Intranet/Extranet recently, I was asked to provide a static Google map for both staff and visitors to find the Head Office location.

The main problem with this is that Google want you to use a static API key for each URL that will refer a connection. Obviously if you’re using alternate access mapping then this will be a problem as internal staff may be connecting to http://intranet whilst your customers may be using http://extranet.myhouse.com

The simplest way that i could see of fixing this problem is to use Javascript in a content editor webpart to look at the Document.URL and output the correct IMG tag accordingly. I also wanted to ensure that it wouldn’t matter if we had a port in the URL, so I’ve stripped that as well.

Here’s the code.


EDIT: Ok, I’m really not happy with the way this code plugin is formatting pasted scripts.. they look fine in the editor but awful on the site. I’ll leave this one as is for now and hopefully sort out a better code display block asap. EDITEDIT Much better.. I changed to the WP-Syntax plugin which seems to work.

Reg.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.