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
|
<?php
if(isset($_POST['addr']))
$addr = $_POST['addr'];
?>
<!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" xml:lang="fr">
<head>
<title>Test Google Maps</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var latlng = new google.maps.LatLng(48.862014, 2.275344);
var initialiser = function() {
var options = {
center: latlng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new google.maps.Map(document.getElementById("map"), options);
var options = {
position: latlng,
map: map
};
var marker = new google.maps.Marker(options);
marker.setMap(map);
<?php
if(isset($addr))
echo "createMarker(\"".$addr."\");\n";
?>
};
var createMarker = function(addr) {
alert("On crée un marker à l'adresse suivante : " + addr);
};
var recupLng = function() {
return latLng.lng;
};
</script>
</head>
<body onload="initialiser()">
<h1>Récupération des coordonnées d’un marker déplaçable</h1>
<form action="test.php" id="form_adresse" name="form_adresse" method="post">
<center>
<input type="text" id="addr" name="addr" size="60" value="Entrer l'adresse ici ! " onFocus="if(this.value == this.defaultValue) this.value = ''" onBlur="if(this.value == '') this.value = this.defaultValue;">
<input type="submit" value="Valider">
</center>
</form>
<br/>
<?php if(isset($_POST['addr'])) { ?>
<center>
Longitude : <input type="text" name="lng" value="0" readonly="readonly" />
Latitude : <input type="text" name="lat" value="0" readonly="readonly" />
</center>
<br/>
<div id="map" style="width:100%; height:100%"></div>
<?php } ?>
</body>
</html> |