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: case 200:
$data = json_decode($response->getBody()); $data = json_decode($response->getBody());
$data->trip->locations = $this->decode_polyline($data->trip->route);
// Cache the downloaded file if it does not exist locally. // Cache the downloaded file if it does not exist locally.
if (Storage::disk('local')->missing($tripFileName)) { if (Storage::disk('local')->missing($tripFileName)) {
Log::debug("Caching new trip file '{$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; return $data->trip;
default: default:
// TODO: Add proper error handling. // TODO: Add proper error handling.

View file

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