2023-07-15 15:03:08 +07:00
|
|
|
<template>
|
2023-07-29 06:47:47 +07:00
|
|
|
|
|
|
|
<searchbar/>
|
|
|
|
|
2023-07-15 17:52:21 +07:00
|
|
|
<ol-map
|
|
|
|
:loadTilesWhileAnimating="true"
|
|
|
|
:loadTilesWhileInteracting="true"
|
2023-07-29 02:10:58 +07:00
|
|
|
style=
|
2023-08-02 01:51:43 +07:00
|
|
|
"
|
|
|
|
height: 100%;
|
2023-07-29 02:10:58 +07:00
|
|
|
width: 100%;
|
2023-08-02 01:34:46 +07:00
|
|
|
position: fixed;
|
|
|
|
"
|
2023-08-23 22:44:12 +07:00
|
|
|
@click="handleMapClick"
|
2023-07-15 17:52:21 +07:00
|
|
|
>
|
|
|
|
<ol-view
|
|
|
|
ref="view"
|
|
|
|
:center="center"
|
|
|
|
:rotation="rotation"
|
|
|
|
:zoom="zoom"
|
|
|
|
:projection="projection"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<ol-tile-layer>
|
|
|
|
<ol-source-osm />
|
|
|
|
</ol-tile-layer>
|
|
|
|
</ol-map>
|
2023-07-29 06:47:47 +07:00
|
|
|
|
2023-07-15 15:03:08 +07:00
|
|
|
</template>
|
|
|
|
|
2023-07-15 17:52:21 +07:00
|
|
|
|
2023-07-29 02:10:58 +07:00
|
|
|
|
2023-07-15 15:03:08 +07:00
|
|
|
<script setup>
|
2023-07-29 06:47:47 +07:00
|
|
|
|
|
|
|
import searchbar from '@/components/searchbar.vue';
|
2023-07-15 17:52:21 +07:00
|
|
|
import { ref } from "vue";
|
2023-08-23 22:44:12 +07:00
|
|
|
import axios from "axios";
|
2023-07-15 17:52:21 +07:00
|
|
|
|
2023-07-29 02:10:58 +07:00
|
|
|
const center = ref([100.538611, 13.764722]);
|
2023-07-15 17:52:21 +07:00
|
|
|
const projection = ref("EPSG:4326");
|
2023-07-29 02:10:58 +07:00
|
|
|
const zoom = ref(19);
|
2023-07-15 17:52:21 +07:00
|
|
|
const rotation = ref(0);
|
2023-08-23 22:44:12 +07:00
|
|
|
|
|
|
|
const handleMapClick = async event => {
|
|
|
|
const clickedCoordinate = event.coordinate;
|
|
|
|
console.log("Clicked coordinate:", clickedCoordinate);
|
|
|
|
|
|
|
|
try {
|
|
|
|
const response = await axios.get(
|
|
|
|
`https://nominatim.openstreetmap.org/reverse?format=json&lat=${clickedCoordinate[1]}&lon=${clickedCoordinate[0]}`
|
|
|
|
);
|
|
|
|
|
|
|
|
console.log("API response:", response.data);
|
|
|
|
|
|
|
|
const nearestStructureData = response.data;
|
|
|
|
console.log("Nearest structure:", nearestStructureData);
|
|
|
|
} catch (error) {
|
|
|
|
console.error("Error fetching reverse geocoding data:", error);
|
|
|
|
}
|
|
|
|
};
|
2023-08-02 01:34:46 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.ol-zoom{
|
|
|
|
top: 40px;
|
|
|
|
}
|
2023-08-02 01:51:43 +07:00
|
|
|
.ol-attribution ul{
|
|
|
|
padding:1px .5em;
|
|
|
|
margin-bottom: 8em;
|
|
|
|
}
|
2023-08-02 01:34:46 +07:00
|
|
|
</style>
|