Google Maps API

by JL Beeken on 9-21-2008

Google Maps APIFellow JLikians, makers of genealogy wikis, how about moveable maps? Google Maps API is here to show you how.

And there are lots of map styles. Any of them can be embedded in html pages.

First you’ll need a Google Account. Then you’ll need to go to Google Earth API and apply for a key. You will then be given your key and example code. Copy and paste the code into a text editor and save it with an html extension.

This is the code you’ll be given:

<htmlxmlns="">    <head>     <metahttp-equiv="content-type"content="text/html; charset=utf-8"/>      <title>Google Maps JavaScript API Exampletitle>     <scriptsrc=""             type="text/javascript">script>     <scripttype="text/javascript">      function initialize(){       if(GBrowserIsCompatible()){          var map =new GMap2(document.getElementById("map_canvas"));           map.setCenter(newGLatLng(37.4419, -122.1419),13);       }     }     script>     head>   <bodyonload="initialize()"onunload="GUnload()">     <divid="map_canvas"style="width: 500px; height: 300px">div>   body>html>

Where it says key=abcdefg, this is where your personal Google Maps API key will go, if it’s not already there.

Where it says LatLng, this example is centered on Palo Alto, CA. You can change it to whatever you want. The co-ordinates in Legacy will have to be changed to decimal. ie. 372631N becomes 37.2631. 1220831W becomes -122.0831.

Here’s how to find the latitude and longitude of any location in Google Maps. After you’re focused on your position, right-click and click on ‘What’s here?’ and it will pop the co-ordinates into the search box.

‘map_canvas’ represents the size of the map on your html page and can be changed.

Meanwhile, back at your genealogy wiki. Link from a location (and you should have plenty of them by now) to the mapname.html you’ve created using code like this: [[Placename|foldername/mapname.html]]

Google Maps API will also give code for embedding many other types of maps. Google Maps API Examples. You don’t have to write the code or even understand it. If you download the examples you can modify the simpler things like title, co-ordinates and map size.

{ 0 comments… add one now }

Leave a Comment

Powered by sweet Captcha

Previous post:

Next post: