1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| <script type="text/javascript">
var map = null;
var geocoder = null;
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GMapTypeControl());
map.addControl(new GLargeMapControl());
GEvent.addListener(map, "moveend", function() {
var center = map.getCenter();
document.getElementById("message").value = center.toString();
});
map.setCenter(new GLatLng(48.862004474432936, 2.350902557373047), 5 );
map.enableDoubleClickZoom();
geocoder = new GClientGeocoder();
}
}
function showAddress(address) {
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address +' '+"Désolé je trouve pas cela dans ma base!");
} else {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(address);
}
}
);
}
}
//]]>
</script>
<script src="http://maps.google.com/maps?file=api&v=2&key=...></script>
<title>
test
</title>
<body onload="load()" onunload="GUnload()">
<form method="post" action="#" onsubmit="showAddress(this.address.value ); return false">
<p>Je cherche : (ex :nom ville, france)
<input type="text" class="form" size="63" name="address" value="<? echo ''.$ville.'' ; ?> <? echo ''.$cpostal.'' ; ?>" />
<br />
La latitude / longitude est:
<input type="text" class="form" id="message" name="message" size="50" value="">
</p>
<p>
<input name="submit" id="button" type="submit" value="J'y vais!" />
</p>
<div id="map" style="width: 650px; height: 500px"></div>
</form> |
Partager