I have a list of point of interests from which I need to select only the x closest ones from my point of origin.
I used the google distance matrix api in order to compute the walking time required to travel from the origin to each destinations. I did the sorting inside the callback function, since the result is only available inside this scope. This works just fine. The inputs are two arrays : one storing the coordinates of the origin and the other the coordinates of each destination.
Here is my problem : I want to do the same thing, but regarding the travel time using the transit system. I can't use the distance matrix api since it doesn't accept transit as a travel method. Instead, I used the Direction service api. But in that case, the function only accepts 1 origin and 1 destination, so I can't compute the comparison between each route from within the function. But again, I can't access the results outside this scope before they are being integrated on my webpage.
Any piece of advice would be much appreciated !