|
|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="light-map">
|
|
|
+ <div class="light-map" :class="{ 'full': full }">
|
|
|
<map
|
|
|
id="prevMap"
|
|
|
map-id="prevMap"
|
|
|
@@ -59,7 +59,9 @@ const villageData = new Map<number, VillageListItem>();
|
|
|
const emit = defineEmits(['getedCurrentLonlat','update:isLightMode']);
|
|
|
|
|
|
const props = defineProps<{
|
|
|
- isLightMode: boolean;
|
|
|
+ startLonlat?: { longitude: number, latitude: number } | undefined;
|
|
|
+ isLightMode?: boolean;
|
|
|
+ full?: boolean;
|
|
|
}>();
|
|
|
|
|
|
const regionLoader = useSimpleDataLoader(async () => {
|
|
|
@@ -227,21 +229,35 @@ onMounted(async () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ if (props.startLonlat) {
|
|
|
+ currentLonlat.value = props.startLonlat;
|
|
|
+ mapCtx.moveToLocation({
|
|
|
+ latitude: currentLonlat.value.latitude,
|
|
|
+ longitude: currentLonlat.value.longitude,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
await regionLoader.loadData(undefined, true);
|
|
|
|
|
|
- const res = await LightVillageApi.getIpAddress();
|
|
|
- currentLonlat.value = {
|
|
|
- longitude: Number(res.point.x),
|
|
|
- latitude: Number(res.point.y),
|
|
|
- };
|
|
|
- await waitTimeOut(100);
|
|
|
- currentAddress.value = res.address_detail.district;
|
|
|
- setCurrentRegion(res.address_detail.district);
|
|
|
- emit('getedCurrentLonlat', currentLonlat.value);
|
|
|
- mapCtx.moveToLocation({
|
|
|
- latitude: currentLonlat.value.latitude,
|
|
|
- longitude: currentLonlat.value.longitude,
|
|
|
- });
|
|
|
+ if (!props.startLonlat) {
|
|
|
+ const res = await LightVillageApi.getIpAddress();
|
|
|
+ currentLonlat.value = {
|
|
|
+ longitude: Number(res.point.x),
|
|
|
+ latitude: Number(res.point.y),
|
|
|
+ };
|
|
|
+ await waitTimeOut(100);
|
|
|
+ currentAddress.value = res.address_detail.district;
|
|
|
+ setCurrentRegion(res.address_detail.district);
|
|
|
+ emit('getedCurrentLonlat', currentLonlat.value);
|
|
|
+ mapCtx.moveToLocation({
|
|
|
+ latitude: currentLonlat.value.latitude,
|
|
|
+ longitude: currentLonlat.value.longitude,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ const address = await MapApi.regeo(currentLonlat.value.latitude, currentLonlat.value.longitude);
|
|
|
+ currentAddress.value = address.district;
|
|
|
+ setCurrentRegion(address.district);
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
</script>
|
|
|
@@ -254,6 +270,15 @@ onMounted(async () => {
|
|
|
border-radius: 30rpx;
|
|
|
overflow: hidden;
|
|
|
|
|
|
+ &.full {
|
|
|
+ height: 100vh;
|
|
|
+ border-radius: 0;
|
|
|
+
|
|
|
+ .light-map-map {
|
|
|
+ height: 100vh;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
.light-map-map {
|
|
|
width: 100%;
|
|
|
height: 600rpx;
|