From 8ea19a6bb34daab1410f6186992a4c1e90299c92 Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Wed, 14 Sep 2022 08:54:44 +0800
Subject: [PATCH] 服务器配置
---
leafletMapOur/grabOrdersMap/js/getPosition.js | 202 +++++++++++++++++++++++++++++--------------------
1 files changed, 119 insertions(+), 83 deletions(-)
diff --git a/leafletMapOur/grabOrdersMap/js/getPosition.js b/leafletMapOur/grabOrdersMap/js/getPosition.js
index 8bcbe5b..42085b4 100644
--- a/leafletMapOur/grabOrdersMap/js/getPosition.js
+++ b/leafletMapOur/grabOrdersMap/js/getPosition.js
@@ -1,9 +1,9 @@
class $getPositions {
constructor(arg) {
this.id = arg.id || 0; //任务id
- this.fn = arg.fn ? function(data) {
+ this.fn = arg.fn ? function (data) {
arg.fn(data);
- } : function(data) {
+ } : function (data) {
console.log("未设置输出回调")
return data;
};
@@ -15,6 +15,7 @@
this.isContinued = false;
this.isContinuedTimeInt = null;
this.isContinuedTimeOut = null;
+ this.geolocation = null; //定位实例
return this;
}
//开始获取
@@ -32,13 +33,13 @@
console.log("重复开始持续定位")
return;
} else {
- that.once(function(res) {
+ that.once(function (res) {
if (res.state == false) {
console.log(res.intlat)
}
})
this.isContinuedTimeInt = setInterval(() => {
- that.once(function(res) {
+ that.once(function (res) {
if (res.state == false) {
console.log(res.intlat)
}
@@ -49,22 +50,23 @@
continuedTime(val) {
//开始持续获取定位
let that = this;
+ that.geolocation = new qq.maps.Geolocation("T7RBZ-62U3X-RSQ4P-ZZVCB-WE7JT-HRBOG", "mapqq");
if (val != 1) {
- console.log("开始持续定位")
+ // console.log(that.id,"开始持续定位")
this.isContinued = true;
- that.once(function(res) {
+ that.once(function (res) {
if (res.state == false) {
// console.log(res.intlat)
that.outData();
}
})
if (this.isContinuedTimeOut) {
- console.log("重复开始持续定位")
+ // console.log("重复开始持续定位")
return;
}
}
this.isContinuedTimeOut = setTimeout(() => {
- that.once(function(res) {
+ that.once(function (res) {
if (res.state == false) {
// console.log(res.intlat)
that.outData();
@@ -77,11 +79,11 @@
}
}
})
- }, 5000)
+ }, 3000)
}
overContinued() {
- console.log("结束持续定位")
+ // console.log("结束持续定位")
let that = this;
if (this.isContinued) {
this.isContinued = false;
@@ -93,24 +95,20 @@
clearTimeout(that.isContinuedTimeOut);
this.isContinuedTimeOut = null;
}
+ if (this.geolocation) {
+ this.geolocation = null;
+ }
}
+ this.isContinued = false;
+ that.outData('out');
}
- // overContinued() {
- // console.log("结束持续定位")
- // let that = this;
- // if (this.isContinued) {
- // this.isContinued = false;
- // clearInterval(that.isContinuedTimeInt);
- // this.isContinuedTimeInt = null;
- // }
- // }
once(fn) {
- console.log("开始获取一次定位");
+ // console.log("开始获取一次定位");
this.state = true;
let ok = true;
let that = this,
- fns = fn,
- outit = function() {
+ fns = fn || '',
+ outit = function () {
if (fns) {
fns({
state: that.state,
@@ -122,61 +120,49 @@
}
};
outit();
- let success = function(position) {
- // console.log(position);
- var lat = position.coords.latitude;
- var lon = position.coords.longitude;
- // 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 = true;
- outit();
- };
- let options = {
- enableHighAccuracy: true,
- // timeout: 5000,
- timeout: Infinity,
- maximumAge: 0,
- };
- this.getOnceSPosition = navigator.geolocation.getCurrentPosition(
- success,
- error,
- options
- );
- //高德定位
- // console.log("开始获取一次定位");
- // this.state = true;
- // let that = this;
- // that.outData();
+ // uni定位
+ console.log(uni.getLocation)
+ //qq定位
+ // var geolocation = new qq.maps.Geolocation("T7RBZ-62U3X-RSQ4P-ZZVCB-WE7JT-HRBOG", "mapqq");
+ // console.log(that.geolocation)
+ // var options = {
+ // // timeout: 1000
+ // };
+
+ // function showPosition(position) {
+ // console.log("position:", position)
+ // console.log("position:", JSON.stringify(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();
+ // };
+ // that.geolocation.getLocation(showPosition, showErr, options);
+ // 高德定位
+ // console.log(AMap)
// AMap.plugin("AMap.Geolocation", function() {
// var geolocation = new AMap.Geolocation({
// // 是否使用高精度定位,默认:true
// enableHighAccuracy: true,
// // 设置定位超时时间,默认:无穷大
- // // timeout: 10000,
+ // 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);
@@ -184,35 +170,85 @@
// function onComplete(data) {
// // data是具体的定位信息
- // // console.log(data);
+ // console.log(data);
// var lat = data.position.lat;
// var lon = data.position.lng;
- // // console.log("成功返回经纬度信息");
- // // console.log(lon, lat, "成功");
- // that.onceNowPosition = [lon, lat];
- // this.state = false;
- // that.outData();
+ // that.onceNowPosition = [lat, lon];
+ // that.state = false;
+ // ok = true;
+ // outit();
// }
// function onError(data) {
// // 定位出错
- // // console.log(data);
- // that.onceNowPosition = data;
- // this.state = false;
- // that.outData();
+ // 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() {
}
//抛出数据
- outData() {
+ outData(val) {
let d = {
state: this.state,
intlat: this.onceNowPosition
}
+ if (val) {
+ d[val] = val
+ }
this.fn(d)
}
}
+
+// export default $getPositions;
\ No newline at end of file
--
Gitblit v1.9.3