GDirections getDistance();

177 views
Skip to first unread message

Icy

unread,
Sep 16, 2011, 12:46:45 AM9/16/11
to Gothere API
Hi,

Can anyone help me with the this problem?

I am trying to get the distance between 2 places.

This is my code:

var directions = new GDirections(map);

var options = { travelMode: G_TRAVEL_MODE_TRANSIT };
directions.load("from:Singapore Polytechnic to:Ngee
Ann Polytechnic", options);
var noofroute = directions.getNumRoutes();
alert(noofroute);

All the above code works fine, until the following, it starts giving
me error about distance.

var distance = directions.getDistance().meters;
alert(distance);

I am using asp.net btw.

Icy,
Thanks in Advance.

Icy

unread,
Sep 16, 2011, 12:50:06 AM9/16/11
to Gothere API
"Microsoft JScript runtime error: Unable to get value of the property
'Distance': object is null or undefined"

This is the error I keep getting...

Icy

unread,
Sep 16, 2011, 3:25:05 AM9/16/11
to Gothere API
Great, I found the solution.

Gotta add the Event Listener for GDirection's Load Function.

Thanks ! :)
> > Thanks in Advance.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages