Fix polyline decoding

This commit is contained in:
Ben Goldsworthy 2023-01-14 20:08:56 +00:00
parent c55d572ec4
commit 97b85e1380
2 changed files with 5 additions and 5 deletions

View File

@ -149,6 +149,8 @@ class TrackerController extends Controller
case 200:
$data = json_decode($response->getBody());
$data->trip->locations = $this->decode_polyline($data->trip->route);
// Cache the downloaded file if it does not exist locally.
if (Storage::disk('local')->missing($tripFileName)) {
Log::debug("Caching new trip file '{$tripFileName}'.");
@ -173,8 +175,6 @@ class TrackerController extends Controller
}
}
$data->trip->locations = $this->decode_polyline($data->trip->route);
return $data->trip;
default:
// TODO: Add proper error handling.

View File

@ -51,7 +51,7 @@
/*
* Initialise the map
*/
var map = L.map('map');//.setView([{{ end($trip->locations)->latitude }}, {{ end($trip->locations)->longitude }}], 7);
var map = L.map('map');
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: 'OpenStreetMap'
@ -127,8 +127,8 @@
*/
map.fitBounds([
@if ($trip->is_active)
@foreach(array_slice(array_reverse($trip->locations), 0, 25) as $location)
[{{ $location->latitude }}, {{$location->longitude }}],
@foreach(array_slice(array_reverse($trip->checkins), 0, 25) as $checkin)
[{{ $checkin->location->latitude }}, {{$checkin->location->longitude }}],
@endforeach
@else
@foreach($trip->locations as $location)