Tuesday, 4 December 2007

Create a Google Maps Web Part - FREE!

So you are looking at creating a google map web part for your MOSS web site and for FREE and done in minutes.



Well this can be achieved in minutes and you could surprise yourself! There is no special development required to achieve this, just a little bit of HTML, a link out to the web from your MOSS server as the google map api will need to communicate to the google map server and a google API key which you can request from here. The google API key, is a key that will be mailed to you from google, once you have submitted the google api key form, you will need to agree to Google Standard Terms and Conditions and provide the URL of your MOSS site.

PreReq
1. MOSS Server
2. Goggle API Key

How Too
1. Open a Moss site where you would like to place your Goggle Map web part.
2. Place a Content Editor Web Part in the Page of the site.
3. Edit the content Editor Web Part and in the proerties of this web part open the source editor. Do not use the Ruch Text Editor.
4. Copy and paste the folloing code in the sorce editor:



<script src="http://maps.google.com/maps?file=api&v=1&key=ADD_YOUR_GOGGLE_API_KEY_HERE" type="text/javascript"></script>
<div id="map" style="width: 400px;height:300px"></div>
<script type="text/javascript">
<![CDATA[
var map = new
GMap(document.getElementById("map"));
map.centerAndZoom(new
GPoint(-0.160265, 51.51443), 3);

//]]>
</script>

5. Apply and OK.
6. And Voila!

There is a good site that will get you the latitude and longitude coordinates of your desired location, that will be used when communicating to the google map server:

http://geo.localsearchmaps.com/?street=45+Oxford+Street&city=London&country=UK

Notice in the URL that you could send the street, city, country and you will be returned with a text page if the co-ordinates that you can use.

If you want to add scaling and repositioning to your web part then add the following into your code, after the var map = ...... Line:

map.addControl(new GLargeMapControl());

This can be achieved in a matter of a few minutes and can save you some money. I have seen companies charging $400.00 for this.




You can also add mapping markers and Location descriptions into your web part very easily.