Commit 2a241981 authored by Hasith Yoman's avatar Hasith Yoman

distance calculation changes

parent 21c8ce93
......@@ -31,6 +31,17 @@ class StationController extends Controller
}
return response()->json(['respond'=>$respond,'count'=>$queue]);
}
public function getAPIDistance($point1,$point2){
$key = "AIzaSyAqCHZnyToOOkw4fiumXxC5oTEaEVAIISA";
$response = Http::get('https://maps.googleapis.com/maps/api/directions/json?origin='.$point1.'&destination='.$point2.'&key='.$key);
if ($response->ok()) {
$data = $response->json();
return $data['routes'][0]['legs'][0]['distance']['text'];
} else {
return "not calculated";
}
}
// calculate distance
public function calculateDistance($lat1, $lon1, $lat2, $lon2) {
$theta = $lon1 - $lon2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment