| 12
 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
 
 |  
<script type="text/javascript">
initialize()
var geocoder;
 
//ajout de l'option pour que l'utilisateur puisse selectionner un point sur la carte
GEvent.addListener(map, "click", function(overlay, latlng) {
  if (latlng) {
	marker = new GMarker(latlng, {draggable:true});
	GEvent.addListener(marker, "click", function() {
	  var html = "<input type='button' value='Selectionner cette position' onclick='saveData()'/ style=\"margin-top : 25px;\">";
 
	  marker.openInfoWindow(html);
	});
	map.addOverlay(marker);
	var address = latlng.lat() +","+ latlng.lng();
	geocoder.getLocations(address, addAddressToMap);
  }
});
 
function addAddressToMap(response) {
  if (!response || response.Status.code != 200) {
	alert("Sorry, we were unable to geocode that address");
  } else {
	place = response.Placemark[0];
 
	var locality_name= place.addressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality.DependentLocalityName;
 
	alert(locality_name);
  }
}
geocoder = new GClientGeocoder();
 
</script> | 
Partager