问题
For more than a week, I have been searching for a way to find the correct distance between two areas and what Google offers is calculating the distance on the map and not directions, either using the Google matrix is very expensive especially since I have a large number of stores and every customer will search to find the closest stores that are supposed to Not more than 10 km away from him, I looked for a solution using the osrm project, but I did not find a way to run it through my site. I ask you to help me because this matter is very necessary for me and I hope that my question will not be closed.
from documentation:
curl 'http://router.project-osrm.org/route/v1/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219?overview=false'
even this I tried it is not working for every time, I changed the latitude and longitude also doesn't work
the error: file_get_contents(http://router.project-osrm.org/route/v1/driving/2.9860749,101.780664;2.8427795,101.79740?overview=false): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
$from_latlong='2.9860749,101.780664';
$to_latlong='2.8427795,101.79740';
$response = file_get_contents("http://router.project-osrm.org/route/v1/driving/$from_latlong;$to_latlong?overview=false");
$data = json_decode($response);
return $data;
来源:https://stackoverflow.com/questions/62619521/laravel-how-to-get-the-exact-distance-and-direction-between-two-points-using-os