Here's my code, simple enough:

<html>
<head>
<script type='text/javascript' src='http://www.google.com/jsapi?
key=ABQIAAAAoN9kM0QqONCLIWU4yHeIJhSgG_jKAmzdssu2U-
M8Edy2G0i_1hSCzKKxGUYV0SPXEMkIwZR4qQPugQ'></script>
<script type='text/javascript'>
//<![CDATA[

google.load('maps', '2');
var gdir2;
var gdir37;
var gdir140;
var gdir225;
function load() {
  if (GBrowserIsCompatible()) {
    gdir2 = new google.maps.Directions();
    google.maps.Event.addListener(gdir2, 'load', handleLoad);
    gdir2.load('from: 413 Old Ithaca Road Horseheads NY 14845 to: 79
Spencer Rd,Candor,NY 13743', {getSteps: true});

    gdir37 = new google.maps.Directions();
    google.maps.Event.addListener(gdir37, 'load', handleLoad);
    gdir37.load('from: 413 Old Ithaca Road Horseheads NY 14845 to: 305
Grant Ave  1,Endicott,NY 13760', {getSteps: true});

    gdir140 = new google.maps.Directions();
    google.maps.Event.addListener(gdir140, 'load', handleLoad);
    gdir140.load('from: 413 Old Ithaca Road Horseheads NY 14845 to: RT
23 ,Norwich,NY 13815', {getSteps: true});

    gdir225 = new google.maps.Directions();
    google.maps.Event.addListener(gdir225, 'load', handleLoad);
    gdir225.load('from: 413 Old Ithaca Road Horseheads NY 14845 to: 30
South Broad St  1,Norwich,NY 13464', {getSteps: true});

  }
}


function handleLoad(){
  document.getElementById('2').innerHTML=gdir2.getDistance().html;
  document.getElementById('37').innerHTML=gdir37.getDistance().html;
  document.getElementById('140').innerHTML=gdir140.getDistance().html;
  document.getElementById('225').innerHTML=gdir225.getDistance().html;
}
window.onload = load;
</script>

</head>
<body>
855520939<br />
<b>Side Hill Acres Goat Farm</b><br />79 Spencer Rd<br />Candor,NY
13743
<div id='2'>...</div><br>
<b>Down to Earth Whole Foods</b><br />305 Grant Ave, 1<br /
>Endicott,NY  13760
<div id='37'>...</div><br>
<b>Evans Farmhouse and Creamery</b><br />RT 23 <br />Norwich,NY  13815
<div id='140'>...</div><br>
<b>Solstice Whole Foods and Herbs</b><br />30 South Broad St, 1<br /
>Norwich,NY  13464
<div id='225'>...</div><br>

Done!
</body>
</html>

It runs fine and updates all DIVs w/ accurate distances, but the
Browser consistently gives a gdir140.getDistance().html is null or not
an object error on line 38, which is the "  document.getElementById
('225').innerHTML=gdir225.getDistance().html;" line in my handleLoad
function.

In the end, this is all to be a hidden function in between when a user
types in an address and sees a list of addresses sorted by distance
(nearest to farthest). My plan is to put the distance data in a
temporary dB table (probably named using the SessionID) and then load
it to the "Results" page from the dB (very, very easy). I know I could
use a client-side array or something like that, but my way will work,
too...I just gotta solve this Javascript error thing first.

Thanks!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to