瀏覽代碼

Task H5定位等待指示器

rongxin_dev
Zhao 18 小時之前
父節點
當前提交
6fefd1df69
共有 2 個文件被更改,包括 15 次插入1 次删除
  1. +8
    -1
      src/components/Map/MapGisLine.vue
  2. +7
    -0
      src/components/Map/MapGisTagDTGCopy.vue

+ 8
- 1
src/components/Map/MapGisLine.vue 查看文件

@@ -23,6 +23,7 @@
import {getQueryLand} from "@/api/homesteadSurvey/zjdzd";
import $ from "jquery";
import { getConfigKey } from "@/api/system/config";
import {Toast} from "vant";

export default {
components: {
@@ -147,11 +148,15 @@ export default {
// 2. 再尝试浏览器
if (navigator.geolocation) {
console.log('使用浏览器获取定位');
const loading = Toast.loading({
message: '定位中...',
duration: 0,
});
let timeout = this.getLocationTimeout();
navigator.geolocation.getCurrentPosition(
(position) => {
const { latitude, longitude } = position.coords;
console.log('浏览器定位结果: 经纬度=' + longitude + ', ' + latitude);1
console.log('浏览器定位结果: 经纬度=' + longitude + ', ' + latitude);
let res = {
code: 200,
data: {
@@ -159,9 +164,11 @@ export default {
lat: latitude,
},
};
loading.clear();
callback(res);
},
(error) => {
loading.clear();
console.log('定位失败: ' + error.message);
getQueryLand().then(callback);
},


+ 7
- 0
src/components/Map/MapGisTagDTGCopy.vue 查看文件

@@ -21,6 +21,7 @@
import Cookies from "js-cookie";
import {getQueryLand} from "@/api/homesteadSurvey/zjdzd";
import { getConfigKey } from "@/api/system/config";
import {Toast} from "vant";

export default {
data() {
@@ -143,6 +144,10 @@
// 2. 再尝试浏览器
if (navigator.geolocation) {
console.log('使用浏览器获取定位');
const loading = Toast.loading({
message: '定位中...',
duration: 0,
});
let timeout = this.getLocationTimeout();
navigator.geolocation.getCurrentPosition(
(position) => {
@@ -155,9 +160,11 @@
lat: latitude,
},
};
loading.clear();
callback(res);
},
(error) => {
loading.clear();
console.log('定位失败: ' + error.message);
getQueryLand().then(callback);
},


Loading…
取消
儲存