20/07 2007

Using the Google Maps API to add maps to your site

The basics….

Adding Google Maps to your own websites is very simple and straightforward and can be done by completing the following steps:

1. Goto http://www.google.com/apis/maps/ (requires that you have a Google account)

2. Click on the link to sign up for a Google Maps API Key

3. Specify the domain name of your website, agree to the terms and conditions and click on the link to generate the API key.

You now have your Google Maps API key which is valid for all pages under the domain name you entered (and is also valid for testing on your local machine when accessed using localhost).

4. Copy and paste the example web page which Google provides into a new file and upload this to your webserver. Try it out and see what you get… it should look something like this: View Example Page

Google provide a very extensive library of documentation and examples which you can use to alter the appearance of the map, add markers to locations, calculate routes between 2 or more locations and lots more. You can find all this here: Google Maps API Documentation

UK geocoding…

One problem many people face when using Google Maps with UK addresses is that you cannot get the geocodes (longitude and latitude) for UK postcodes. The reason behind this is that the UK Post Office has the rights to all UK postcodes and charge for converting them to their geocodes.

There have been many attempted free solutions to this problem but from my experience none of them work very well or are not long term solutions. After lots of searching I did find one solution which works using the Google AJAX Search API.

Please visit this tutorial by Tom Anthony which details how to do this.

I hope this brief introduction to Google Maps has been helpful - happy mapping!

back me up

No replies to “Using the Google Maps API to add maps to your site”