Danke für die Infos!
Hab jetzt schon was gefunden, da geb ich die Adresse ein, und in der GoogleMap werden mir die Koordinaten ausgegeben.
Wie kann ich das Script so verändern, dass die Koordinaten auch auf der Seite in einem div angezeigt werden und nicht nur in der Karte in dieser Sprechblase??
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Geokoordinaten ermitteln</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<script src="http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAAOib38z8vZp0Mqcyn89RgJxTwXb8fng98Seg-9wdDnp9R1SdaqhTkFlkW3jtTAdtat2dzHY7vDek5eQ" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var map = null;
var geocoder = null;
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(51.51780970491161, 7.464040517807007), 17);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
geocoder = new GClientGeocoder();
showAddress(document.forms["address_form"].address.value);
}
}
function showInfoWindow(marker, address, eventstr) {
var str = marker.getPoint()+ " ";
str = str.replace( /\(|\)/g, "" );
var coord = str.split(",");
var lat = coord[0];
var lon = coord[1];
marker.openInfoWindowHtml("<b>"+ address + "</b><br/><br/>"+eventstr+"<br/>Longitude, Latitude: <h3>" + lon + ", " + lat + "</h3><br/><br/>" );
}
function showAddress(address) {
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " konnte nicht geokodiert werden!");
} else {
map.setCenter(point, 17);
var marker = new GMarker(point, {draggable: true} );
GEvent.addListener(marker, "dragstart", function() {
map.closeInfoWindow();
});
GEvent.addListener(marker, "dragend", function() {
showInfoWindow(marker,address, "Neue Position");
});
GEvent.addListener(marker, "click", function() {
showInfoWindow(marker,address,"");
});
map.addOverlay(marker);
showInfoWindow(marker,address,"");
}
}
);
}
}
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<form name="address_form" action="#" onsubmit="showAddress(this.address.value); return false">
<p>
<input type="text" size="60" name="address" value="berlin" />
<input type="submit" value="Go!" />
<br/>Straße, Ort, Land zur Geokodierung eingeben:<br/>
</p>
<div id="map" style="width: 550px; height: 550px; border:1px solid red;"></div>
</form>
</body>
</html>