From 53f5367d635ecfde9ceb36fe3bcafa86c32275a8 Mon Sep 17 00:00:00 2001
From: liuyg <liuyg@qq.com>
Date: Tue, 22 Feb 2022 16:41:04 +0800
Subject: [PATCH] +地图更新成uniapp

---
 leafletMapOur/grabOrdersMap/js/getPosition.js |   92 ++++++++++++++++++++++++----------------------
 1 files changed, 48 insertions(+), 44 deletions(-)

diff --git a/leafletMapOur/grabOrdersMap/js/getPosition.js b/leafletMapOur/grabOrdersMap/js/getPosition.js
index ac30d71..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;
 		};
@@ -33,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)
 					}
@@ -54,7 +54,7 @@
 		if (val != 1) {
 			// 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();
@@ -66,7 +66,7 @@
 			}
 		}
 		this.isContinuedTimeOut = setTimeout(() => {
-			that.once(function(res) {
+			that.once(function (res) {
 				if (res.state == false) {
 					// console.log(res.intlat)
 					that.outData();
@@ -108,7 +108,7 @@
 		let ok = true;
 		let that = this,
 			fns = fn || '',
-			outit = function() {
+			outit = function () {
 				if (fns) {
 					fns({
 						state: that.state,
@@ -120,14 +120,18 @@
 				}
 			};
 		outit();
+		// 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(JSON.stringify(position))
+		// 	console.log("position:", position)
+		// 	console.log("position:", JSON.stringify(position))
 		// 	let lat = position.lat; //
 		// 	let lng = position.lng; //火星坐标 //TODO 实现业务代码逻辑 
 		// 	that.onceNowPosition = [lng, lat];
@@ -147,43 +151,43 @@
 		// 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(JSON.stringify(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(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(JSON.stringify(data));
-				that.onceNowPosition = data.message;
-				that.state = false;
-				ok = false;
-				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);
@@ -247,4 +251,4 @@
 	}
 }
 
-// export default $getPositions;
+// export default $getPositions;
\ No newline at end of file

--
Gitblit v1.9.3