topical media & game development

talk show tell print

professional-ria-03-YahooGeoCode.js / js



  // Yahoo GeoCoder Functions Encapsulated
  // (c) Dana Moore, Ray Budd, Ted Benson
  
  function callWS(target, request) {
      if(target !== ""){
          var url = '../../phpscripts/geocoder.php?' + encodeURI(target);
  //        alert("callWS...\n"+url);
          request.open('GET', url, true);
          request.onreadystatechange = function() {
              if(request.readyState == 4 && request.status == 200) {
                  alert("callWS:onreadystatechange...\n"+request.responseText);
                  document.getElementById('Result').innerHTML = '';
                  parseResult(request.responseText);
              } else {
                  document.getElementById('State').innerHTML = "Loading...";
              }
          };
          request.send(null);
      }
  }
  
  function parseResult(result){
      var start = (result.search(/<Latitude>/) +10 );
      var end = result.search(/<\/Latitude>/);
      var lat = result.substr(start, (end -start) );
  
      start = (result.search(/<Longitude>/) +11 );
      end = result.search(/<\/Longitude>/);
      var lon = result.substr(start, (end -start) );
  
      alert("parseResult:\n"+"Lat:"+lat+"\nLon:"+lon);
      return new Array (lat, lon);
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.