เช็คเวลาต้องลงเวลาเข้าหรือออกงาน (USER)

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-11-15 18:08:42 +07:00
parent 3083ea8dcb
commit 07b02a7818
4 changed files with 128 additions and 22 deletions

View file

@ -7,10 +7,11 @@ const center = ref<any>()
const location = ref<string>('')
const test = ref()
// hook
onMounted(() => {
findNearestPlace()
})
const emit = defineEmits(["update:location"]);
const updateLocation = (location: any, namePOI: string) => {
// event parent component props
emit("update:location", location, namePOI);
};
//
function findNearestPlace() {
@ -25,7 +26,6 @@ function findNearestPlace() {
// Location API
findNearestPlaceFromAPI(userLocation)
center.value = userLocation
console.log(center.value)
},
(error) => {
console.error(error)
@ -36,6 +36,8 @@ function findNearestPlace() {
console.error('เบราว์เซอร์ไม่รองรับการระบุตำแหน่ง')
}
}
function findNearestPlaceFromAPI(userLocation: any) {
const placesService = new google.maps.places.PlacesService(
document.createElement('div')
@ -49,15 +51,22 @@ function findNearestPlaceFromAPI(userLocation: any) {
placesService.nearbySearch(request, (results: any, status: any) => {
if (status === google.maps.places.PlacesServiceStatus.OK) {
console.log('Nearby places:', results[0])
// console.log('Nearby places:', results[0])
const place = results[0]
location.value = place.name
test.value = place.geometry.location
updateLocation(center.value,location.value)
} else {
console.error('Error fetching nearby places:', status)
}
})
}
// hook
onMounted(() => {
findNearestPlace()
})
</script>
<template>