Open sidebar
$link = "https://maps.googleapis.com/maps/api/directions/json?origin=" . $from . "&destination=" . $track->to . "&key=" . env('GOOGLE_MAPS_API_KEY'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, str_replace(' ', '%20', $link)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); $api = json_decode($output); $start['lat'] = $api->routes[0]->legs[0]->start_location->lat; $start['lng'] = $api->routes[0]->legs[0]->start_location->lng; $end['lat'] = $api->routes[0]->legs[0]->end_location->lat; $end['lng'] = $api->routes[0]->legs[0]->end_location->lng; $distance = $api->routes[0]->legs[0]->distance->text; $duration['text'] = $api->routes[0]->legs[0]->duration->text; $duration['value'] = $api->routes[0]->legs[0]->duration->value;
Close sidebar
Back
Please note that all pasted data is publicly available.
X (fomerly Twitter)
GitHub
Use setting
Back
Please note that all pasted data is publicly available.
X (fomerly Twitter)
GitHub
Use setting