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
   |  
function loadAddress()
   {
	  var address = document.getElementById('addressText').value;
 
      // Create new geocoding object
      geocoder = new GClientGeocoder();
 
      // Retrieve location information, pass it to addToMap()
      geocoder.getLocations(address, addToMap);
   }
 
 
   function createMarker(point)
   {
   map = new GMap2(document.getElementById("map"));
   var marker = new GMarker(point);
   map.addOverlay(marker);
 
  marker.openInfoWindowHtml(place.address + '<br>' + 
  '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
  }
 
   // This function adds the point to the map
 
   function addToMap(response)
   {
 
 
      // Retrieve the object
      place = response.Placemark[0];
 
	  point = new GLatLng(place.Point.coordinates[1],
                        place.Point.coordinates[0]);
						alert(point);
 
	createMarker(point);
 
 
      // Retrieve the latitude and longitude
 
	var xhr=null;
 
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
 
    xhr.open("POST", "./recup.php", true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	var name = document.getElementById("nameText").value;
    xhr.send("lg="+place.Point.coordinates[1]+"&lat="+place.Point.coordinates[0]+"&name="+name+"&address="+place.address);
 
 
   } | 
Partager