The documentation for the Distance Matrix API is clear. It states for both origins and destinations parameters that
"If you pass coordinates, ensure that no space exists between the latitude and longitude values." But it appears to me that adding spaces to the coordinates actually yields better results.
For example, say I'm going from Bourke St Bakery to the Flinders Hotel in Surry Hills, Sydney. Google geocodes the these two locations as...
Bourke Street Bakery (633 Bourke Street Surry Hills NSW)
"location" : {
"lat" : -33.8894280,
"lng" : 151.2148370
},
Flinders Hotel (63 Flinders St Surry Hills NSW 2010)
"location" : {
"lat" : -33.88313090,
"lng" : 151.21736560
}
Passing those values to the Distance Matrix API I get back the following.
{
"destination_addresses" : [ "Eastern Distributor Motorway, Darlinghurst NSW 2010, Australia" ],
"origin_addresses" : [ "255 Devonshire St, Surry Hills NSW 2010, Australia" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "3.5 km",
"value" : 3545
},
"duration" : {
"text" : "6 mins",
"value" : 375
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
See how the addresses are wrong now?
However, if I add space between the latitude and longitude I get a more accurate, correct answer!...
{
"destination_addresses" : [ "63 Flinders St, Surry Hills NSW 2010, Australia" ],
"origin_addresses" : [ "633 Bourke St, Surry Hills NSW 2010, Australia" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "3.5 km",
"value" : 3532
},
"duration" : {
"text" : "6 mins",
"value" : 354
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
What's up with that??