From fa6eb4e94b2496773a281b0fac5582871e7d7b7a Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Tue, 22 Feb 2022 11:00:43 +0800
Subject: [PATCH] 反馈问题修复
---
public/grabOrdersMap/js/getPosition.js | 145 +++++++++++++++++++++++++++++++++++-------------
1 files changed, 105 insertions(+), 40 deletions(-)
diff --git a/public/grabOrdersMap/js/getPosition.js b/public/grabOrdersMap/js/getPosition.js
index 7a4ac09..bf87d99 100644
--- a/public/grabOrdersMap/js/getPosition.js
+++ b/public/grabOrdersMap/js/getPosition.js
@@ -1,3 +1,4 @@
+
class $getPositions {
constructor(arg) {
this.id = arg.id || 0; //任务id
@@ -115,50 +116,114 @@
}
};
outit();
- let success = function(position) {
- // console.log(position);
- var lat = position.coords.longitude;//经度
- var lon = position.coords.latitude;//纬度
- // console.log("成功返回经纬度信息");
- // console.log(lon, lat, "成功");
- that.onceNowPosition = [lat, lon];
+ //qq定位
+ var geolocation = new qq.maps.Geolocation("T7RBZ-62U3X-RSQ4P-ZZVCB-WE7JT-HRBOG", "mapqq");
+ var options = {
+ // timeout: 1000
+ };
+
+ function showPosition(position) {
+ let lat = position.lat; //
+ let lng = position.lng; //火星坐标 //TODO 实现业务代码逻辑
+ that.onceNowPosition = [lng, lat];
+ // console.log(that.onceNowPosition)
+ that.state = false;
+ ok = true;
+ outit();
+ }
+
+ function showErr(data) {
+ console.log(data)
+ that.onceNowPosition = data;
that.state = false;
ok = true;
outit();
};
- let error = function(error) {
- // console.log(error, "失败");
- let msg = "none";
- switch (error.code) {
- case error.PERMISSION_DENIED:
- msg = "User denied the request for Geolocation.";
- break;
- case error.POSITION_UNAVAILABLE:
- msg = "Location information is unavailable.";
- break;
- case error.TIMEOUT:
- msg = "The request to get user location timed out.";
- break;
- case error.UNKNOWN_ERROR:
- msg = "An unknown error occurred.";
- break;
- }
- that.onceNowPosition = msg;
- that.state = false;
- ok = false;
- outit();
- };
- let options = {
- enableHighAccuracy: true,
- // timeout: 5000,
- timeout: Infinity,
- maximumAge: 0,
- };
- this.getOnceSPosition = navigator.geolocation.getCurrentPosition(
- success,
- error,
- options
- );
+ geolocation.getLocation(showPosition, showErr, options);
+ // 高德定位
+ // console.log(AMap)
+ // AMap.plugin("AMap.Geolocation", function() {
+ // var geolocation = new AMap.Geolocation({
+ // // 是否使用高精度定位,默认:true
+ // enableHighAccuracy: true,
+ // // 设置定位超时时间,默认:无穷大
+ // timeout: 10000,
+ // // 定位按钮的停靠位置的偏移量,默认:Pixel(10, 20)
+ // // buttonOffset: new AMap.Pixel(10, 20),
+ // // 定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
+ // // zoomToAccuracy: true,
+ // // 定位按钮的排放位置, RB表示右下
+ // // buttonPosition: "RB",
+ // });
+ // geolocation.getCurrentPosition();
+ // AMap.event.addListener(geolocation, "complete", onComplete);
+ // AMap.event.addListener(geolocation, "error", onError);
+
+ // function onComplete(data) {
+ // // data是具体的定位信息
+ // console.log(data);
+ // var lat = data.position.lat;
+ // var lon = data.position.lng;
+ // that.onceNowPosition = [lat, lon];
+ // that.state = false;
+ // ok = true;
+ // outit();
+ // }
+
+ // function onError(data) {
+ // // 定位出错
+ // console.log(data);
+ // that.onceNowPosition = data.message;
+ // that.state = false;
+ // ok = false;
+ // outit();
+ // }
+ // });
+ // return
+ // let success = function(position) {
+ // // console.log(position);
+ // var lat = position.coords.longitude; //经度
+ // var lon = position.coords.latitude; //纬度
+ // // console.log("成功返回经纬度信息");
+ // // console.log(lon, lat, "成功");
+ // that.onceNowPosition = [lat, lon];
+ // that.state = false;
+ // ok = true;
+ // outit();
+ // };
+ // let error = function(error) {
+ // // console.log(error, "失败");
+ // let msg = "none";
+ // switch (error.code) {
+ // case error.PERMISSION_DENIED:
+ // msg = "User denied the request for Geolocation.";
+ // break;
+ // case error.POSITION_UNAVAILABLE:
+ // msg = "Location information is unavailable.";
+ // break;
+ // case error.TIMEOUT:
+ // msg = "The request to get user location timed out.";
+ // break;
+ // case error.UNKNOWN_ERROR:
+ // msg = "An unknown error occurred.";
+ // break;
+ // }
+ // that.onceNowPosition = msg;
+ // that.state = false;
+ // ok = false;
+ // outit();
+ // };
+ // let options = {
+ // enableHighAccuracy: true,
+ // // timeout: 5000,
+ // timeout: Infinity,
+ // maximumAge: 0,
+ // };
+ // this.getOnceSPosition = navigator.geolocation.getCurrentPosition(
+ // success,
+ // error,
+ // options
+ // );
}
//结束获取
outInit() {
--
Gitblit v1.9.3