What you are doing should not work even with addWaypoint. You need to
move tsp.getOrder() and tsp.getDurations() into the onSolveCallback
function. The call to tsp.solveRoundTrip is asynchronous (so it
returns before the computation is done). The results are not ready
until onSolveCallback is called.
Geir
On Fri, May 17, 2013 at 3:22 PM, Cannect <
kee...@cannect.nl> wrote:
> Hello all,
>
> Thanks for taking the time for me. The title describes it well, the setup
> below works only with tsp.AddWaypoint(). Possible my adresses are wrong?
> For me it is most important to get the trip order and total trip duration.
>
> var myOptions = {
> zoom: 12,
> center: new google.maps.LatLng(52.119999,5.866699),
> mapTypeId: google.maps.MapTypeId.ROADMAP
> };
> myMap = new google.maps.Map(document.getElementById("map"),
> myOptions);
>
> directionsPanel = document.getElementById("routebeschrijving");
>
> tsp = new BpTspSolver(myMap, directionsPanel);
>
> tsp.setTravelMode(google.maps.DirectionsTravelMode.DRIVING);
>
> tsp.addAddress('Amsterdam, the netherlands');
> tsp.addAddress('ede, the netherlands');
> tsp.addAddress('arnhem, the netherlands');
> tsp.addAddress('Groningen, the netherlands');
>
> tsp.solveRoundTrip(onSolveCallback);
>
> var order = tsp.getOrder();
> var durations = tsp.getDurations();
> console.log(order);
> console.log(durations);
>
> }
>
> function onSolveCallback(theTsp){
> }
> function addWaypointCallback(theTsp){
> }
>
>
> Thanks in advance!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps TSP Solver" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
google-maps-tsp-s...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>