Knowledge Base Nr: 00288 googlemaps.txt - http://www.swe-kaiser.de

Downloads:

Ajax: Google Maps in eigene Seite einbauen

  
Ein neuer Schlüssel für eine domain kann unter http://code.google.com/apis/maps/ generiert werden.

<!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=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIA..KKFCNd3aGbuf8No60zzOpWP7pUA"
type="text/javascript"></script>
<script type="text/javascript">

//<![CDATA[

var map = null;

function load()
{
if (GBrowserIsCompatible())
{
map = new GMap2(document.getElementById("map"));

map.addControl(new GMapTypeControl());
map.addControl(new GLargeMapControl());
map.addControl(new GScaleControl());
map.setCenter(new GLatLng(49.04549422, 7.88025884), 13);
map.openInfoWindow(map.getCenter(), document.createTextNode("Triftholzhof 1864 - 1879"));
}
}

function getpos()
{
if (GBrowserIsCompatible())
{
var pos = map.getCenter();
alert(pos);
alert(pos.toUrlValue());
}
}

var geocoder = new GClientGeocoder();

function showAddress(address)
{
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " not found");
} else {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(address);
}
}
);
}

//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<h1>mein google map api test</h1>
<div id="map" style="width: 800px; height: 600px"></div>
<p>
noch im entstehen begriffen ... <br />
<a href="#" onclick="getpos();">get center position</a><br />
<a href="#" onclick="showAddress('kirchstr. 13, b�llenborn, germany');">show boellenborn position</a><br />
<a href="#" onclick="showAddress('im oberen grain 12, deidesheim, germany');">show deidesheim position</a><br />
</p>
</body>
</html>