From a8f65a646f2d5e463cc1826425a8294ebf7bcf01 Mon Sep 17 00:00:00 2001
From: liuyg <liuyg@qq.com>
Date: Tue, 22 Feb 2022 14:51:08 +0800
Subject: [PATCH] +fname发布者字段
---
leafletMapOur/grabOrdersMap/js/getPosition.js | 121 +++++++++++++++++++++-------------------
1 files changed, 63 insertions(+), 58 deletions(-)
diff --git a/leafletMapOur/grabOrdersMap/js/getPosition.js b/leafletMapOur/grabOrdersMap/js/getPosition.js
index bf87d99..ac30d71 100644
--- a/leafletMapOur/grabOrdersMap/js/getPosition.js
+++ b/leafletMapOur/grabOrdersMap/js/getPosition.js
@@ -1,4 +1,3 @@
-
class $getPositions {
constructor(arg) {
this.id = arg.id || 0; //任务id
@@ -16,6 +15,7 @@
this.isContinued = false;
this.isContinuedTimeInt = null;
this.isContinuedTimeOut = null;
+ this.geolocation = null; //定位实例
return this;
}
//开始获取
@@ -50,6 +50,7 @@
continuedTime(val) {
//开始持续获取定位
let that = this;
+ that.geolocation = new qq.maps.Geolocation("T7RBZ-62U3X-RSQ4P-ZZVCB-WE7JT-HRBOG", "mapqq");
if (val != 1) {
// console.log(that.id,"开始持续定位")
this.isContinued = true;
@@ -78,7 +79,7 @@
}
}
})
- }, 30000)
+ }, 3000)
}
overContinued() {
@@ -93,6 +94,9 @@
if (this.isContinuedTimeOut) {
clearTimeout(that.isContinuedTimeOut);
this.isContinuedTimeOut = null;
+ }
+ if (this.geolocation) {
+ this.geolocation = null;
}
}
this.isContinued = false;
@@ -117,68 +121,69 @@
};
outit();
//qq定位
- var geolocation = new qq.maps.Geolocation("T7RBZ-62U3X-RSQ4P-ZZVCB-WE7JT-HRBOG", "mapqq");
- var options = {
- // timeout: 1000
- };
+ // 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 showPosition(position) {
+ // console.log(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();
- };
- geolocation.getLocation(showPosition, showErr, options);
+ // 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,
- // // 定位按钮的停靠位置的偏移量,默认: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);
+ 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 onComplete(data) {
+ // data是具体的定位信息
+ console.log(JSON.stringify(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();
- // }
- // });
+ function onError(data) {
+ // 定位出错
+ console.log(JSON.stringify(data));
+ that.onceNowPosition = data.message;
+ that.state = false;
+ ok = false;
+ outit();
+ }
+ });
// return
// let success = function(position) {
// // console.log(position);
--
Gitblit v1.9.3