Hi, i have to create an application in Java, which can calculate the
total distance/traveltime employees have to drive to a specified
location.

I thought this would be easy using the GDirections object from the
API, but this does not work. Because there is some delay between the
directions.load() and the moment the distance is filled
(directions.getDistance().meters), so this gives me null errors.

this is an example of the function:

function calculateDistance(){
    totalDistance=0;
    for (i = 0; i < persons.length; i++) {
        var directions = new GDirections();
        var str = "from: " + persons[i].latitude + " " + persons
[i].longitude +
            " to: " + latDestination + " " + lngDestination;
        directions.load(str);
        totalDistance = totalDistance + directions.getDistance().meters;
    }
    ...
};

I've tried this also with a listener (GEvent.addListener...) but this
only works for the first employee in persons.

Is there anyone who knows the solution?
Or could i try to use a webservice like the geocoder service but for
directions?

Is there anyone who would know a possible solution for this problem?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to Google-Maps-API@googlegroups.com
To unsubscribe from this group, send email to 
google-maps-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to