ปรับ code ลงเวลาเข้า-ออกงาน (USER)
This commit is contained in:
parent
07b02a7818
commit
9f6fffd73c
2 changed files with 94 additions and 78 deletions
|
|
@ -7,13 +7,13 @@ const center = ref<any>()
|
|||
const location = ref<string>('')
|
||||
const test = ref()
|
||||
|
||||
const emit = defineEmits(["update:location"]);
|
||||
const emit = defineEmits(['update:location'])
|
||||
const updateLocation = (location: any, namePOI: string) => {
|
||||
// ส่ง event ไปยัง parent component เพื่ออัพเดทค่า props
|
||||
emit("update:location", location, namePOI);
|
||||
};
|
||||
emit('update:location', location, namePOI)
|
||||
}
|
||||
|
||||
// หาตำแหน่ง
|
||||
/** function หาตำแหน่ง*/
|
||||
function findNearestPlace() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
|
|
@ -37,7 +37,10 @@ function findNearestPlace() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* function หาสถานที่ที่ใกล้ที่สุด
|
||||
* @param userLocation พิกัดละติจูด พิกัดลองจิจูด
|
||||
*/
|
||||
function findNearestPlaceFromAPI(userLocation: any) {
|
||||
const placesService = new google.maps.places.PlacesService(
|
||||
document.createElement('div')
|
||||
|
|
@ -55,8 +58,7 @@ function findNearestPlaceFromAPI(userLocation: any) {
|
|||
const place = results[0]
|
||||
location.value = place.name
|
||||
test.value = place.geometry.location
|
||||
updateLocation(center.value,location.value)
|
||||
|
||||
updateLocation(center.value, location.value)
|
||||
} else {
|
||||
console.error('Error fetching nearby places:', status)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue