// file = geocode /* geocode.js Description : Call the geocode.php script to get a kml file from google.com based on a specified address, decode it and display links in the GUI Contributors: Pascal Vitoux (pascal@vitoux.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ function resetSearchForm() { document.getElementById ("findLocationResponse").innerHTML = ""; } function geocode (address) { document.getElementById ("findLocationResponse").innerHTML = "Recherche en cours..."; document.getElementById ("findLocationResponse").className = ""; //document.getElementById ("submitLocationSearchButton").disabled = true; resizeMe (); treatPlaces = function(response) { if (response.Status.code != 200) { document.getElementById ("findLocationResponse").innerHTML = "Pas de résultats trouvés"; document.getElementById ("findLocationResponse").className = "erreur"; } else { // var max = 3; // if (max > response.Placemark.length) { max = response.Placemark.length; // } document.getElementById ("findLocationResponse").innerHTML = "

Résultats de la recherche:

"; for (var i = 0; i < max; i++) { coords = response.Placemark[i].Point.coordinates; address = response.Placemark[i].address; document.getElementById ("findLocationResponse").innerHTML += '

' + address + "

"; } resizeMe (); } } geocoder.getLocations(address + ', France', treatPlaces); /* var request = GXmlHttp.create (); request.open ('GET', 'geocode.php?address=' + address, true); request.onreadystatechange = function () { if (request.readyState == 4) { //Populate with elements in the updated feed var doc = request.responseXML; document.getElementById ("findLocationResponse").innerHTML = "

Resultats de la recherche:

"; var count = 0; placemarks = doc.documentElement.getElementsByTagName("Placemark"); for(var i = 0; i < placemarks.length; i++) { var point = placemarks[i].getElementsByTagName("Point")[0]; var coords = point.getElementsByTagName("coordinates")[0].childNodes[0].nodeValue; //document.getElementById ("findLocationResponse").innerHTML += coords; coords = coords.split(","); var address = placemarks[i].getElementsByTagName("address")[0].childNodes[0].nodeValue; document.getElementById ("findLocationResponse").innerHTML += '

' + address + "

"; resizeMe (); count ++; } document.getElementById ("submitLocationSearchButton").disabled = false; resizeMe (); } } request.send (null);*/ }