Fabulous! That worked. I can't tell you how long I sat and stared at
that one wondering why it did not work. Aargh.
By the way Mike, thanks a bunch for the examples from your web page.
they are very helpful. Without the online resources, I would be sunk
for this project. If you want to post this code to your page, I would
be happy to donate it. I think it could have some utility, especially
for some people doing research projects. Also, a big thanks to google
for supporting the maps api. Here's my final code (a few small changes
from the previously posted):

<pre>
-------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
<link href="/style.css" rel="stylesheet" type="text/css" />
<title>Miles to ... using Maps API</title>
<script type="text/javascript" src="http://www.google.com/jsapi?key=
[your Google API Key]"></script>

<script type="text/javascript">
//<![CDATA[
google.load("maps", "2");

var addressBlock;
var addressLine = new Array();
var gdira = new Array();
var i;
var addressSplit = new Array();
var totdist="";

function load(i) {
        if (GBrowserIsCompatible()) {
                                addressSplit[i] = addressLine[i].split("\t");
                gdira[i]= new google.maps.Directions();
                google.maps.Event.addListener(gdira[i], "load",
function(){
        totdist = totdist + "\n" + addressSplit[i][2] + "\t" + gdira
[i].getDistance().html;
        document.getElementById("totalMiles").innerHTML = totdist;
});

google.maps.Event.addListener(gdira[i], "error", function(){
        totdist = totdist + "\n" + addressSplit[i][2] + "\tError " + gdira
[i].getStatus().code;
});
                gdira[i].load("from: " + addressSplit[i][0] + " to: "
+ addressSplit[i][1] , {getSteps: true});
        }
}

function loop(form){
addressBlock = form.inputbox.value;
addressLine = addressBlock.split("\n");
var len=addressLine.length;
for(i=0; i<len; i++) {
        setTimeout( "load("+i+")" , i*500);
}
}

window.onunload = google.maps.Unload;
//]]>
</script>
</head>
 <body>
 <FORM NAME="myform" ACTION="" METHOD="GET">
Paste from excel- Address From, Address To, Unique Identifier: <BR>
<TEXTAREA NAME="inputbox" VALUE="" cols="100" rows="10"></TEXTAREA><P>
Output: <BR>
<TEXTAREA NAME="outputbox" id="totalMiles" VALUE="" cols="100"
rows="10"></TEXTAREA><P>
<INPUT TYPE="button" NAME="button1" Value="Start" onClick="loop
(this.form)">

</FORM>
    </body>
</html>

----
</pre>
--~--~---------~--~----~------------~-------~--~----~
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