Building a store locator app with the google maps (static) distance matrix API to find the distance between the user location and list of predefined stores with lat long etc.
When we get the response we just map it to a list and all the rest works great.
We now need the closest store to be listed first. i.e in below case, the 1100km store will be listed as list item one and then the 2109km one...
is there any way i can do this coz google maps api doesnt have a sort option.
sample response:
{
"destination_addresses" : [ "lxyx" ],
"origin_addresses" : [ "lxyz", "Ixyz" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "2 109 km",
"value" : 2109034
},
"duration" : {
"text" : "1 jour 8 heures",
"value" : 114405
},
"status" : "OK"
}
]
},
{
"elements" : [
{
"distance" : {
"text" : "1 110 km",
"value" : 1109948
},
"duration" : {
"text" : "18 heures 33 minutes",
"value" : 66785
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}