|
|
@@ -5,6 +5,7 @@
|
|
|
map-id="prevMap"
|
|
|
class="light-map-map"
|
|
|
:enable-poi="false"
|
|
|
+ show-location
|
|
|
:scale="12"
|
|
|
:longitude="AppCofig.defaultLonLat[0]"
|
|
|
:latitude="AppCofig.defaultLonLat[1]"
|
|
|
@@ -44,6 +45,7 @@ import Button from '@/components/basic/Button.vue';
|
|
|
import { navTo } from '@/components/utils/PageAction';
|
|
|
import CommonContent from '@/api/CommonContent';
|
|
|
import { waitTimeOut } from '@imengyu/imengyu-utils';
|
|
|
+import { toast } from '@/components/utils/DialogAction';
|
|
|
|
|
|
const instance = getCurrentInstance();
|
|
|
const mapCtx = uni.createMapContext('prevMap', instance);
|
|
|
@@ -76,7 +78,7 @@ const mapLoader = useSimpleDataLoader<MapMarker[]>(async () => {
|
|
|
villageData.clear();
|
|
|
|
|
|
await waitTimeOut(200);
|
|
|
- const res = (await LightVillageApi.getVillageList(undefined, selectedRegion.value, undefined, 1, 100000000000)).map((p, i) => {
|
|
|
+ const res = (await LightVillageApi.getVillageList(undefined, selectedRegion.value, undefined, 1, 500)).map((p, i) => {
|
|
|
villageData.set(p.id, p);
|
|
|
const maker : MapMarker = {
|
|
|
id: p.id ?? i,
|
|
|
@@ -191,23 +193,33 @@ function setCurrentRegion(regionName: string) {
|
|
|
mapLoader.loadData(undefined, true);
|
|
|
}
|
|
|
|
|
|
-function getCurrentLonlat() {
|
|
|
- uni.getLocation({
|
|
|
- type: 'wgs84',
|
|
|
- success: async (res) => {
|
|
|
- currentLonlat.value = {
|
|
|
- longitude: res.longitude,
|
|
|
- latitude: res.latitude,
|
|
|
- };
|
|
|
- const address = await MapApi.regeo(res.latitude, res.longitude);
|
|
|
- currentAddress.value = address.district;
|
|
|
- setCurrentRegion(address.district);
|
|
|
- emit('getedCurrentLonlat', currentLonlat.value);
|
|
|
- mapCtx.moveToLocation({
|
|
|
- latitude: currentLonlat.value.latitude,
|
|
|
- longitude: currentLonlat.value.longitude,
|
|
|
- });
|
|
|
- },
|
|
|
+async function getCurrentLonlat() {
|
|
|
+ const res = await new Promise<{ longitude: number, latitude: number }>((resolve, reject) => {
|
|
|
+ uni.getLocation({
|
|
|
+ type: 'wgs84',
|
|
|
+ success: async (res) => {
|
|
|
+ resolve(res);
|
|
|
+ },
|
|
|
+ fail() {
|
|
|
+ toast('获取定位失败');
|
|
|
+ resolve({
|
|
|
+ longitude: AppCofig.defaultLonLat[0],
|
|
|
+ latitude: AppCofig.defaultLonLat[1],
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
+ });
|
|
|
+ currentLonlat.value = {
|
|
|
+ longitude: res.longitude,
|
|
|
+ latitude: res.latitude,
|
|
|
+ };
|
|
|
+ const address = await MapApi.regeo(res.latitude, res.longitude);
|
|
|
+ currentAddress.value = address.district;
|
|
|
+ setCurrentRegion(address.district);
|
|
|
+ emit('getedCurrentLonlat', currentLonlat.value);
|
|
|
+ mapCtx.moveToLocation({
|
|
|
+ latitude: currentLonlat.value.latitude,
|
|
|
+ longitude: currentLonlat.value.longitude,
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -261,6 +273,12 @@ onMounted(async () => {
|
|
|
longitude: Number(res.point.x),
|
|
|
latitude: Number(res.point.y),
|
|
|
};
|
|
|
+ if (isNaN(currentLonlat.value.longitude) || isNaN(currentLonlat.value.latitude)) {
|
|
|
+ currentLonlat.value = {
|
|
|
+ longitude: AppCofig.defaultLonLat[0],
|
|
|
+ latitude: AppCofig.defaultLonLat[1],
|
|
|
+ };
|
|
|
+ }
|
|
|
await waitTimeOut(100);
|
|
|
currentAddress.value = res.address_detail.district;
|
|
|
setCurrentRegion(res.address_detail.district);
|