I noticed a little bug in class google.maps.DirectionsService.
In Google Maps Javascript API V3 Reference we can read this about destination (and about origin) property:
But be careful! If you give coordinates in string the finally route will contains some differences from expected route. My suggestion is next to avoid this problem:
aMatches = sDestination.match(/[a-z]*/i);
if(!aMatches.length || (aMatches.length==1 && aMatches[0]=="")) { // no letters in sDestination => this contains only coordinates!
var a = sDestination.split(",");
var oDestination = new google.maps.LatLng(1.0*a[0], 1.0*a[1]);
}
var request = {
...
destination: oDestination ? oDestination : sDestination,
...
};
In Google Maps Javascript API V3 Reference we can read this about destination (and about origin) property:
"Location of destination. This can be specified as either a string to be geocoded or a LatLng. Required."
But be careful! If you give coordinates in string the finally route will contains some differences from expected route. My suggestion is next to avoid this problem:
aMatches = sDestination.match(/[a-z]*/i);
if(!aMatches.length || (aMatches.length==1 && aMatches[0]=="")) { // no letters in sDestination => this contains only coordinates!
var a = sDestination.split(",");
var oDestination = new google.maps.LatLng(1.0*a[0], 1.0*a[1]);
}
var request = {
...
destination: oDestination ? oDestination : sDestination,
...
};