Ph.Creative is a full service design and communications agency specialising in web design, SEO, internet marketing and branding.

Liverpool

London

Manchester

New York

Call us on +44(0)151 708 2280 or liverpool@ph-creative.com

Call us on +44(0)20 3301 4503 or london@ph-creative.com

Call us on +44(0)161 880 0122 or manchester@ph-creative.com

Call us on (001) 646 340 1025 or newyork@ph-creative.com

Add Google Maps On Your Website

by Jim Taylor 14 July 2009 at 12:28

One of my favourite parts of a web development project is adding Google Maps to a web site.
They’re really simple and easy to add and can give your site that extra edge.

So how do you add a google map to your site?

First, request a free key for the Google Maps API here: http://code.google.com/apis/maps/signup.html
Add your web site URL and click Generate. You’ll need to login to your Google account.

You’ll then receive a key which looks similar to this: ABQIAAAAdUEEB1I-1xZFGV-lVIIV2hSY58pY9NDKjzY52-otgNxuDuzzFxQc9CiP4oV_Q6plISDwk2vmhPkYAw

Now add this script below in the Head of your web page, note we’ve added the new key to it.

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=
ABQIAAAAdUEEB1I-1xZFGV-lVIIV2hSY58pY9NDKjzY52-otgNxuDuzzFxQc9CiP4oV
_Q6plISDwk2vmhPkYAw" type="text/javascript"></script>

We’ll need to add another script next, with the coordinates of the pointer on the map.
Use our Google Maps Coordinates Tool to generate Latitude and Longitude co-ordinates. Simply drag the pointer to where you want it or type to search, and then copy the coordinates.

We’ll now add our second script in the head below the one we’ve already added, note we’ve added the coordinates. The number 14 for map.setCenter is the zoom, which you can change.

<script type="text/javascript">
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallZoomControl());
map.enableScrollWheelZoom();
map.setCenter(new GLatLng(53.34870686020199, -6.267356872558594), 14);
}                          
var marker1 = new GMarker(new GLatLng(53.34870686020199,- 6.267356872558594));
map.addOverlay(marker1);
}
//]]>
</script>

We also need to change the body tag to load the map:

<body onLoad="load();" onUnload="GUnload()">

And last but not least you need to add the div in the body where you want your map to go.

<div id=”map”></div>

How easy was that?
You can then start being creative with your maps! Here are some examples:
www.hipentertainment.co.uk/contact-us.phuse
www.ehjoinery.com/contact-us.phuse
www.germwarfare.co.uk/contact-us.phuse

I’ll post a blog on how to add more than one marker on a map soon, so keep a look out!

 

Currently rated 5.0 by 5 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Google | web design | Web Technologies

Comments

Add comment


 

biuquote
  • Comment
  • Preview
Loading




 

Search

Recent Comments

Comment RSS

Our Latest Tweets

Office Music

Don't judge us by our tastes!

© Copyright Ph.Creative 2009. All rights reserved. Terms & Conditions | Privacy Policy | Sitemap (XML) | Log in

Website design by Ph.Creative

^