|
@@ -10,7 +10,7 @@ const emit = defineEmits(['update']);
|
|
|
|
|
|
let props = defineProps({
|
|
|
position: {
|
|
|
- type: Object,
|
|
|
+ type: Array,
|
|
|
default: () => ([])
|
|
|
},
|
|
|
radius: {
|
|
@@ -30,16 +30,16 @@ watch(
|
|
|
let map = null;
|
|
|
let marker = ref('');
|
|
|
let circle = ref('');
|
|
|
-let address = '';
|
|
|
+let address = ref(null);
|
|
|
let geocoder;
|
|
|
|
|
|
window._AMapSecurityConfig = {
|
|
|
- serviceHost: "https://nsrh.ctbu.edu.cn/_AMapService",
|
|
|
+ serviceHost: import.meta.env.VITE_AMAP_HOST,
|
|
|
};
|
|
|
|
|
|
onMounted(() => {
|
|
|
AMapLoader.load({
|
|
|
- key: "d1f123693def8a412c976184daa4b60e",
|
|
|
+ key: import.meta.env.VITE_AMAP_KEY,
|
|
|
version: "2.0",
|
|
|
})
|
|
|
.then((AMap) => {
|
|
@@ -92,13 +92,13 @@ const getAddress = async (position) => {
|
|
|
})
|
|
|
await geocoder.getAddress(position, function (status, result) {
|
|
|
if (status === "complete" && result.info === "OK") {
|
|
|
- address = result.regeocode.formattedAddress;
|
|
|
+ address.value = result.regeocode.formattedAddress;
|
|
|
} else {
|
|
|
- address = '未知';
|
|
|
+ address.value = '未知';
|
|
|
}
|
|
|
loading.close();
|
|
|
//触发更新事件
|
|
|
- emit('update', [position.KL, position.kT], address);
|
|
|
+ emit('update', [position.KL, position.kT], address.value);
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -108,7 +108,6 @@ const drawCircle = () => {
|
|
|
center: props.position,
|
|
|
radius: props.radius,
|
|
|
borderWeight: 1,
|
|
|
- strokeOpacity: 1,
|
|
|
strokeOpacity: 0.2,
|
|
|
fillOpacity: 0.4,
|
|
|
})
|