frontend: createpost: add reverse location lookup to get city and country
Signed-off-by: Nicolas Froger <nicolas@kektus.xyz>
This commit is contained in:
parent
b115ee3d5e
commit
ce2b6338c3
1 changed files with 15 additions and 1 deletions
|
|
@ -159,6 +159,20 @@ function mediaReorder(index, diff) {
|
|||
selectedFiles.value[index + diff] = tmp
|
||||
}
|
||||
|
||||
function getCityAndCountry() {
|
||||
const lat = latitudeInput.value.value
|
||||
const lon = longitudeInput.value.value
|
||||
if (!lat || !lon)
|
||||
return
|
||||
|
||||
fetch(`https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lon}&format=jsonv2`)
|
||||
.then((resp) => resp.json()).then((resp) => {
|
||||
form.setFieldValue('city', resp.address.village)
|
||||
form.setFieldValue('country', resp.address.country)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -228,7 +242,7 @@ function mediaReorder(index, diff) {
|
|||
</FormControl>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
<Button class="place-self-end">
|
||||
<Button class="place-self-end" @click="getCityAndCountry">
|
||||
<RefreshCcw />
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue