update lokasi otomatis dan print out
This commit is contained in:
@@ -218,7 +218,7 @@
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">“Koordinat</label>
|
||||
<label class="form-label max-w-56">Koordinat</label>
|
||||
<div id="perwakilan" class="flex items-baseline w-full gap-5">
|
||||
<div class="grid grid-cols-2 gap-4 items-center w-full">
|
||||
<input class="input" type="text" placeholder="Masukan Koordinat Latitude" type="text"
|
||||
@@ -228,10 +228,12 @@
|
||||
name="kordinat_lng" id="lng"
|
||||
value="{{ old('kordinat_lng', isset($forminspeksi['asset']['kordinat_lng']) ? $forminspeksi['asset']['kordinat_lng'] : '') }}">
|
||||
</div>
|
||||
<a target="_blank" href="https://www.google.com/maps" type="button"
|
||||
class="btn btn-md btn-outline btn-primary">
|
||||
<a onclick="getCoordinates()" type="button" class="btn btn-md btn-outline btn-primary">
|
||||
<i class="ki-filled ki-map"></i>Ambil
|
||||
Koordinat </a>
|
||||
<a target="_blank" href="https://www.google.com/maps" type="button"
|
||||
class="btn btn-md btn-outline btn-success">
|
||||
<i class="ki-filled ki-map"></i>Ke google Maps</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -443,11 +445,9 @@
|
||||
@endphp
|
||||
|
||||
|
||||
<input id="hub_penghuni_tidak_sesuai" class="input"
|
||||
name="hub_penghuni_tidak_sesuai"
|
||||
<input id="hub_penghuni_tidak_sesuai" class="input" name="hub_penghuni_tidak_sesuai"
|
||||
placeholder="Masukkan Hubungin penghuni jaminan"
|
||||
value="{{ old('hub_penghuni_tidak_sesuai', isset($selectedData) ? $selectedData : '') }}"
|
||||
|
||||
style="{{ old('hub_penghuni_tidak_sesuai', $selectedData ?? false) ? '' : 'display: none;' }}">
|
||||
</div>
|
||||
<em id="error-hub_cadeb_penghuni" class="alert text-danger text-sm"></em>
|
||||
@@ -460,6 +460,43 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function getCoordinates() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
(position) => {
|
||||
// Ambil latitude dan longitude
|
||||
const lat = position.coords.latitude;
|
||||
const lng = position.coords.longitude;
|
||||
|
||||
// Masukkan ke dalam input field
|
||||
document.getElementById('lat').value = lat;
|
||||
document.getElementById('lng').value = lng;
|
||||
toastrSuccessBuild('Koordinat berhasil diambil!');
|
||||
|
||||
},
|
||||
(error) => {
|
||||
// Handle error
|
||||
switch (error.code) {
|
||||
case error.PERMISSION_DENIED:
|
||||
toastrErrorBuild('Pengguna menolak permintaan geolokasi.');
|
||||
break;
|
||||
case error.POSITION_UNAVAILABLE:
|
||||
toastrErrorBuild('Informasi lokasi tidak tersedia.');
|
||||
break;
|
||||
case error.TIMEOUT:
|
||||
toastrErrorBuild('Permintaan geolokasi mengalami timeout.');
|
||||
break;
|
||||
case error.UNKNOWN_ERROR:
|
||||
toastrErrorBuild('Terjadi kesalahan yang tidak diketahui.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
toastrErrorBuild('Geolocation tidak didukung oleh browser ini.');
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Cek radio button saat halaman dimuat
|
||||
const sesuaiRadio = document.querySelector('input[name="alamat_sesuai"][value="sesuai"]');
|
||||
|
||||
Reference in New Issue
Block a user