Hi, first of all, sorry about my horrible English but I’m not a native
speaker.

Well, I’m a computer scientist student and as a part of my final
degree project I need to solve the well-known Travelling Salesman
Problem with several complications added.

This problem consists in getting the distance between all specified
points.

For that purpose, I need to get the driving distance between each pair
of nodes (with Google Maps API) and later put into practice an
algorithm that tell me in which order I must visit these nodes (with
PHP) for, subsequently, draw the route in the map (with Google Maps
API).

Well then, the thing that I can’t solve is the obtaining of the
distance between each pair of nodes.

Could you help me?

The page where I’m trying to make it doesn’t work well and I’m
modifying it every day. Anyway, here it is:
http://sqm2.dlsi.ua.es/prj/Pruebas/04-21-Martes/Test.php

This is the key section of the code:
...
<?php
// We suppose that we’ve inserted every point with ‘GMarker’
for(int $origin=0; $origin<count($nodes)-1; $origin++)
{
        Points[0] = <?= $nodes[$origin]; ?>
for(int $destination=$origin+1; $ destination <count($nodes); $
destination ++)
        {
?>
                Points[1] = <?= $nodes[$destination]; ?>
//I've even tested it creating several google.maps.Directions objects
                gdir = new google.maps.Directions();
                google.maps.Event.addListener(gdir, "load", handleLoad);
                gdir.loadFromWaypoints(Points);
<?php
        }
}
?>
//Here, I’d obtain the points in the optimum order for visiting them
and then I’d draw the map


function handleLoad()
{
        alert(gdir.getRoute(0).getDistance().meters);
        alert(gdir.getRoute(0).getDuration().seconds);
        // I’d save the distances for processing them later
}
...

--~--~---------~--~----~------------~-------~--~----~
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