I have a script that is working on Firefox on both Mac and PC and on
Safari, but doesn't work on IE on a PC. I am creating a table that
lists a company and the distance between that company and a user
submitted address. The script is located on a PHP page and every
iteration the loop creates a table row and uses the API to find the
distance between the users address and the respective company. That
is all I need this script to do.
I am receiving this error in IE: gd.getDistance().meters is null or
not an object. This particular loop is only being executed 3 times,
and the error occurs on the first 2 passes, but not on the third, on
the third it executes correctly.
Here is the table portion of the page source:
<table class="sortable" style="width:600px;">
<tr>
<th style="width:30px;"></th>
<th class="pageHeader"
style="font-size:12px;font-weight:500;width:
250px;">Company</th>
<th class="pageHeader"
style="font-size:12px;font-weight:500;width:
250px;">Distance (miles)</th>
<th class="pageHeader"
style="font-size:12px;font-weight:500;width:
70px;">Quote</th>
</tr>
<tr><td style="border-top:solid;border-top-color:#CCCCCC;"><input
type="checkbox" name="0000000002"></td><td style="border-
top:solid;border-top-color:#CCCCCC;">Company 1</td>
<script src="http://maps.google.com/maps?
file=api&v=2.x&sensor=false&key=ABQIAAAA7krqpTmmfiYdkJ0N9Z2iHRQ54BZ5lbd6D3Bd5hI6QK4whcZT8hR98K0EfSgTxgyO9u8EA0uPSlcAkA"
type="text/javascript"></script>
<script type="text/javascript">
<!--
function getDistance(pointA, pointB){
// For this example I'll assume pointA and pointB are
freeform addresses.
var directions = "from: "+pointA+" to: "+pointB;
// Initialize the GDirections class, load the
directions
gd = new GDirections(null,null);
loader = gd.load(directions, {"locale" : "en_US"});
// event listener
GEvent.addListener(gd, "load", onLoader);
}
function onLoader(){
// Grab the distance between point A and point B
var distance = gd.getDistance().meters;
distance = distance/1600;
distance = roundNumber(distance, 1);
var duration = gd.getDuration().html;
// Alert the distance string
document.getElementById('row1').innerHTML = distance;
}
-->
</script>
<script type="text/javascript">getDistance('9506 Greco Garth
Columbia MD 21045', '5409 Graywing Ct Columbia MD 21045');</script><td
style="border-top:solid;border-top-color:#CCCCCC;"><div id="row1"></
div></td><td style="border-top:solid;border-top-color:#CCCCCC;">
$3,000</td></tr><tr><td style="border-top:solid;border-top-
color:#CCCCCC;"><input type="checkbox" name="0000000003"></td><td
style="border-top:solid;border-top-color:#CCCCCC;">Company 2</td>
<script src="http://maps.google.com/maps?
file=api&v=2.x&sensor=false&key=ABQIAAAA7krqpTmmfiYdkJ0N9Z2iHRQ54BZ5lbd6D3Bd5hI6QK4whcZT8hR98K0EfSgTxgyO9u8EA0uPSlcAkA"
type="text/javascript"></script>
<script type="text/javascript">
<!--
function getDistance(pointA, pointB){
// For this example I'll assume pointA and pointB are
freeform addresses.
var directions = "from: "+pointA+" to: "+pointB;
// Initialize the GDirections class, load the
directions
gd = new GDirections(null,null);
loader = gd.load(directions, {"locale" : "en_US"});
// event listener
GEvent.addListener(gd, "load", onLoader);
}
function onLoader(){
// Grab the distance between point A and point B
var distance = gd.getDistance().meters;
distance = distance/1600;
distance = roundNumber(distance, 1);
var duration = gd.getDuration().html;
// Alert the distance string
document.getElementById('row2').innerHTML = distance;
}
-->
</script>
<script type="text/javascript">getDistance('9506 Greco Garth
Columbia MD 21045', '8873 Spiral Cut Columbia MD 21045');</script><td
style="border-top:solid;border-top-color:#CCCCCC;"><div id="row2"></
div></td><td style="border-top:solid;border-top-color:#CCCCCC;">
$81,000</td></tr><tr><td style="border-top:solid;border-top-
color:#CCCCCC;"><input type="checkbox" name="0000000004"></td><td
style="border-top:solid;border-top-color:#CCCCCC;">Company
3 <a href="profile.php?
cleanerID=0000000004&companyNumber=3"
onClick="popUp(this.href,'console',400,350);return false;"
target="_blank"><img src="images/quoteCompanyProfile.gif"
style="vertical-align:middle;border:0;" /></a></td>
<script src="http://maps.google.com/maps?
file=api&v=2.x&sensor=false&key=ABQIAAAA7krqpTmmfiYdkJ0N9Z2iHRQ54BZ5lbd6D3Bd5hI6QK4whcZT8hR98K0EfSgTxgyO9u8EA0uPSlcAkA"
type="text/javascript"></script>
<script type="text/javascript">
<!--
function getDistance(pointA, pointB){
// For this example I'll assume pointA and pointB are
freeform addresses.
var directions = "from: "+pointA+" to: "+pointB;
// Initialize the GDirections class, load the
directions
gd = new GDirections(null,null);
loader = gd.load(directions, {"locale" : "en_US"});
// event listener
GEvent.addListener(gd, "load", onLoader);
}
function onLoader(){
// Grab the distance between point A and point B
var distance = gd.getDistance().meters;
distance = distance/1600;
distance = roundNumber(distance, 1);
var duration = gd.getDuration().html;
// Alert the distance string
document.getElementById('row3').innerHTML = distance;
}
-->
</script>
<script type="text/javascript">getDistance('9506 Greco Garth
Columbia MD 21045', '8800 Greenbelt Rd Greenbelt MD 20770');</
script><td style="border-top:solid;border-top-color:#CCCCCC;"><div
id="row3"></div></td><td style="border-top:solid;border-top-
color:#CCCCCC;">$42,750</td></tr>
</table>
Thanks in advance for any light anyone can shed....I have been pouring
through documentation but no luck.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---