koddanadam
$a = '13.388860,52.517037'; // boylam,enlem
$b = '13.397634,52.529407'; // boylam,enlem
$url = sprintf('https://router.project-osrm.org/route/v1/driving/%s;%s', $a, $b);
$response = Http::get($url)
->throw()
->json();
$distance = $response['routes'][0]['distance']; // metre
$duration = $response['routes'][0]['duration']; // saniye
$route = $response['routes'][0]['geometry']; // Encode edilmiş rota: mfp_I__vpAk~@xHgGgg@{DwW
Google Maps Js API kullanıyorsanız route değeri ile arada çizilen rotayı gösterebilirsiniz:
const route = new google.maps.Polyline({
path: route, // mfp_I__vpAk~@xHgGgg@{DwW
geodesic: true,
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 2,
});