Beginning Google Maps API PDF
Beginning Google Maps API PDF
Follow the steps below to add a simple Google Maps API (pictured below), including
kml layers, to your site. Lots of other utilities can be added to make your map more
dynamic. See the Resources section for helpful links.
2. Insert key:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script src="http://maps.google.com/maps?file=api&v=2&key= "Your
API key code goes here
type="text/javascript"></script>
</head>
3. Declare variables (make sure you do this because IE wont work if you dont):
<body onload="onLoad()" onunload="GUnload()">
<script type="text/javascript">
var map;
var1 = new GGeoXml("insert links to your kml files");
var2 = new GGeoXml("insert links to your kml files");
4. List functions:
function onLoad() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("myMap")); Can use any name
map.setMapType(G_SATELLITE_MAP); Sets initial map to satellite imagery
map.addMapType(G_PHYSICAL_MAP);
map.addControl(new GMapTypeControl());
map.addControl(new GOverviewMapControl());
function boxclick(box,category) {
if (box.checked) {
map.addOverlay(category);
}
else {
map.removeOverlay(category);
}
}
</script>
<table width="800" height="500" border="1" bgcolor="#333333">
<tr>
<th width="600"><div id="myMap" style="width:600px;
height:500px"></div></th>
<th width="200" bgcolor="#CCCCCC"><form id="form1" name="form1"
method="post" action="">
<label>
<input type="checkbox" name="checkbox" value="checkbox"
onclick="boxclick(this, gagesKml)"/>
<span class="style2">Layer 1 </span></label>
</form>
</th>
</tr>
</table>
</body>
</html>
Resources:
Google Maps API Tutorial http://econym.org.uk/gmap/
Google Maps Demo Gallery
http://code.google.com/apis/maps/documentation/demogallery.html
Using Markers http://mapsapi.googlepages.com/categories.htm
Key DragZoom
http://gmaps-utility-library.googlecode.com/svn/trunk/keydragzoom/1.0/docs/examples.html
If you have any questions, feel free to contact me at the email address above.
Good luck!
map.addControl(new GLargeMapControl()
map.addControl(new GMapTypeControl());
http://gce-lter.marsci.uga.edu/public/gis/UntitledTest.html
map.addMapType(G_PHYSICAL_MAP);
map.addControl(new GOverviewMapControl());