From 7cc687814f05ffc2acb69d4b3692adaa6ed22802 Mon Sep 17 00:00:00 2001 From: Daeng Deni Mardaeni Date: Tue, 18 Mar 2025 08:17:30 +0700 Subject: [PATCH] feat(bank-data): tambahkan tombol untuk mendapatkan petunjuk arah - Menambahkan tombol "Get Directions" di tampilan data bank. - Mengimplementasikan fungsi getDirections untuk membuka Google Maps dengan rute dari lokasi pengguna ke lokasi tujuan. - Menggunakan geolocation API untuk mendapatkan lokasi pengguna saat ini. --- resources/views/bank-data/index.blade.php | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/resources/views/bank-data/index.blade.php b/resources/views/bank-data/index.blade.php index 00b184f..360e3c7 100644 --- a/resources/views/bank-data/index.blade.php +++ b/resources/views/bank-data/index.blade.php @@ -320,6 +320,12 @@ +
+
+ +
`; @@ -354,6 +360,26 @@ } } + + function getDirections(lat, lng) { + console.log('Getting directions to:', lat, lng); + if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition( + (position) => { + const origin = position.coords.latitude + ',' + position.coords.longitude; + const destination = lat + ',' + lng; + const url = `https://www.google.com/maps/dir/?api=1&origin=${origin}&destination=${destination}`; + window.open(url, '_blank'); + }, + () => { + alert('Unable to get your current location. Please enable location services.'); + } + ); + } else { + alert('Geolocation is not supported by your browser.'); + } + } + function initializeDataTable() { const element = document.querySelector('#bank-data-table'); const searchInput = document.getElementById('search');