GDirections.GetDistance
I am trying to get the distance of a GDirections.load operation. The
load works fine: lines on the map, directions in the pane. However, I
need to textually access and display the distance. But, all I get is
undefined; I get this for all of the GDirection object's methods.
Please can you help. I am 100% certain the following code is in need
of checking:
function displayDistances(point) {
if (!point) {
return;
}
var offices = getOffices();
var numberOfOffices = offices.length;
for (i = 0; i < 1; i++) {
if( i == 0)
{
writeSWInfo("<br />", true);
}
else
{
writeSWInfo("<br />", false);
}
var display = document.getElementById("SWInfo");
var direction = new GDirections(getMap(), display,
GDirections.preserveViewport, GDirections.getSteps);
writeSWInfo(offices[i].name + "<br />", false);
writeSWInfo(offices[i].address + "<br />", false);
var postCode = offices[i].postCode;
writeSWInfo( postCode + "<br />", false);
direction.load("from:" + point + "to:" + postCode,
document.getElementById("SWInfo"));
var distance = direction.GetDistance();
writeSWInfo("Distance from client: " + distance.meters +
"<br />");
}
}
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home