Browse Source

Don't show cemetery location map if no coordinates available

pull/68/head
Nafies Luthfi 5 years ago
parent
commit
b2ae796b43
  1. 7
      app/Http/Controllers/UsersController.php
  2. 1
      resources/lang/en/app.php
  3. 1
      resources/lang/id/app.php
  4. 27
      resources/views/users/death.blade.php

7
app/Http/Controllers/UsersController.php

@ -106,14 +106,9 @@ class UsersController extends Controller
*/ */
public function death(User $user) public function death(User $user)
{ {
$mapZoomLevel = 4;
$mapZoomLevel = 18;
$mapCenterLatitude = $user->getMetadata('cemetery_location_latitude'); $mapCenterLatitude = $user->getMetadata('cemetery_location_latitude');
$mapCenterLongitude = $user->getMetadata('cemetery_location_longitude'); $mapCenterLongitude = $user->getMetadata('cemetery_location_longitude');
if ($mapCenterLatitude && $mapCenterLongitude) {
$mapZoomLevel = 18;
}
$mapCenterLatitude = $mapCenterLatitude ?: '-0.87887';
$mapCenterLongitude = $mapCenterLongitude ?: '117.4863';
return view('users.death', compact('user', 'mapZoomLevel', 'mapCenterLatitude', 'mapCenterLongitude')); return view('users.death', compact('user', 'mapZoomLevel', 'mapCenterLatitude', 'mapCenterLongitude'));
} }

1
resources/lang/en/app.php

@ -41,4 +41,5 @@ return [
'cancel' => 'Cancel', 'cancel' => 'Cancel',
'open_in_google_map' => 'Open in Google Map', 'open_in_google_map' => 'Open in Google Map',
'data_not_available' => 'Data not available.',
]; ];

1
resources/lang/id/app.php

@ -41,4 +41,5 @@ return [
'cancel' => 'Batal', 'cancel' => 'Batal',
'open_in_google_map' => 'Buka di Google Map', 'open_in_google_map' => 'Buka di Google Map',
'data_not_available' => 'Data tidak tersedia.',
]; ];

27
resources/views/users/death.blade.php

@ -41,6 +41,7 @@
<div class="col-md-6"> <div class="col-md-6">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ __('user.cemetery_location') }}</h3></div> <div class="panel-heading"><h3 class="panel-title">{{ __('user.cemetery_location') }}</h3></div>
@if ($mapCenterLatitude && $mapCenterLongitude)
<div class="panel-body"><div id="mapid"></div></div> <div class="panel-body"><div id="mapid"></div></div>
<div class="panel-footer"> <div class="panel-footer">
@php @php
@ -52,28 +53,31 @@
['class' => 'btn btn-default btn-block', 'target' => '_blank'] ['class' => 'btn btn-default btn-block', 'target' => '_blank']
) }} ) }}
</div> </div>
@else
<div class="panel-body">{{ __('app.data_not_available') }}</div>
@endif
</div> </div>
</div> </div>
</div> </div>
@endsection @endsection
@section('ext_css')
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
@if ($mapCenterLatitude && $mapCenterLongitude)
@section('ext_css')
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
crossorigin=""/> crossorigin=""/>
<style>
<style>
#mapid { height: 300px; } #mapid { height: 300px; }
</style>
@endsection
</style>
@endsection
@section('script')
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
@section('script')
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""></script> crossorigin=""></script>
<script>
<script>
var mapCenter = [{{ $mapCenterLatitude }}, {{ $mapCenterLongitude }}]; var mapCenter = [{{ $mapCenterLatitude }}, {{ $mapCenterLongitude }}];
var map = L.map('mapid').setView(mapCenter, {{ $mapZoomLevel }}); var map = L.map('mapid').setView(mapCenter, {{ $mapZoomLevel }});
@ -82,5 +86,6 @@
}).addTo(map); }).addTo(map);
var marker = L.marker(mapCenter).addTo(map); var marker = L.marker(mapCenter).addTo(map);
</script>
@endsection
</script>
@endsection
@endif
Loading…
Cancel
Save