Some issues:
wypnt.toString().split(",");
this will not have any effect to wypnt, split will not modify the original object. it has to be:
wypnt = wypnt.toString().split(",");
Why are you switching latitude and longitude here?
wypnt = new google.maps.LatLng(wypnt[1],wypnt[0]);
it has to be
wypnt = new google.maps.LatLng(wypnt[0],wypnt[1]);
Most of all: why do you do it at all? you take an array, convert it to a string, split the string to get the original array.
Simply use:
google.maps.event.addListenerOnce(directionsDisplay, 'directions_changed',
function(){
var waypoints=directionsDisplay.getDirections().routes[0]
.legs[0].via_waypoints||[];
for(var i=0;i<waypoints.length;++i){
waypoints[i]={stopover:true,location: waypoints[i]}
}
route(waypoints);
});
But note: when you redraw the route directions_changed
will fire again.