Workshop GoogleMaps Teil 2: Interaktive Markierungen

Listing: Markierungen

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>Google Maps </title>
<?php require("gmap_script_inc.php") ?>
<script type="text/javascript">
//<![CDATA[
var map = null;
var geocoder = null;
var startzoom = 15;

function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
geocoder = new GClientGeocoder();
// add controls
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
showAddress("Marienplatz, München",startzoom);
}
}

function showAddress(address, zoomvalue) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " nicht gefunden");
} else {
map.setCenter(point, zoomvalue);
var marker = new GMarker(point,{title:"Münchner Marienplatz"});
map.addOverlay(marker);
marker.openInfoWindowHtml("Der <b>Marienplatz</b> in München");
}
}
);
}
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width:500px; height: 300px"></div>
</body>
</html>