Thursday, July 21, 2005

Google Maps API: First Shot

I have had a quick look at the programming the Gooogle Maps API.
The heart of the code that produces the map above is simple:
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(-0.104370, 51.512482) , 2);
document.createTextNode("We drank around here last night"));

You need to sign up for a with Google Maps API key to use the system. This only gives you permission to access the maps from a single directory. This is a pain in the neck for a weblog becaue the frontpage, archive and permalink versions of a post are all in different directories. For the moment I have got over this by putting the map in an Iframe.

I think it is quite impressive. Try zooming in on the satellite view. When I next get some time, I will try adding more information to the map using markers.

No comments: