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 />");
          }
      }
-- 
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