From 4230457ee9edca6af738ec3f832ed0f49d0d99c3 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期三, 04 十二月 2024 18:10:30 +0800
Subject: [PATCH] 1.下载地图瓦片判断是否有网。 2.没有上传成功的巡检坐标有网时重新上传。 3.添加网络判断的工具类
---
app/src/main/assets/js/map.js | 69 +++++++++++++++++++++++++---------
1 files changed, 50 insertions(+), 19 deletions(-)
diff --git a/app/src/main/assets/js/map.js b/app/src/main/assets/js/map.js
index a3f9e30..367686b 100644
--- a/app/src/main/assets/js/map.js
+++ b/app/src/main/assets/js/map.js
@@ -48,7 +48,7 @@
// 鍦板浘鐐瑰嚮鍚庤幏鍙栫粡绾害
function getLngLat(lnglat) {
console.log(lnglat.lng.toFixed(6) + "," + lnglat.lat.toFixed(6));
- addClickOverLay(lnglat);
+ // addClickOverLay(lnglat);
}
// 鐐瑰嚮鍚庢坊鍔犲潗鏍囩偣
@@ -169,6 +169,10 @@
window.setCenterAndZoom = setCenterAndZoom;
window.updateLocation = updateLocation;
window.aginShowLocation = aginShowLocation;
+ window.cleanLocationLay = cleanLocationLay;
+ window.updateInspectionLocation=updateInspectionLocation;
+ window.cleanLoclLay=cleanLoclLay;
+
}
// 璋冪敤鍘熺敓瀹夊崜鏂规硶鏄剧ず鍙栨按鍙h鎯�
@@ -271,18 +275,8 @@
});
return "addMarker鍔犺浇鎴愬姛"
}
- //淇濆瓨瀹氫綅鍧愭爣鐢熸垚杞ㄨ抗
- var path = [];
- var lineLayer = new T.Polyline([], { color: '#ff4500', weight: 3, opacity: 0.8 });
- let locationMarker;
+ //鏇存柊瀹氫綅鍧愭爣
function updateLocation(log, lat) {
- var lastLat = lat;
- // const intervalId = setInterval(() => {
- // lastLat=lastLat+0.0001;
- var newPoint = new T.LngLat(log, lastLat);
- path.push(newPoint);
- lineLayer.setLngLats(path);
- map.addOverLay(lineLayer);
let icon = new T.Icon({
iconUrl: locationIMGPath,
iconSize: new T.Point(20, 20),
@@ -291,21 +285,58 @@
if (locationMarker) {
map.removeOverLay(locationMarker);
}
- locationMarker = new T.Marker(new T.LngLat(log, lastLat), { icon: icon });
+ var newPoint = new T.LngLat(log, lat);
+ locationMarker = new T.Marker(newPoint, { icon: icon });
map.addOverLay(locationMarker);
- // 绉诲姩鍦板浘瑙嗚鍒版渶鍚庝竴涓綅缃�
map.panTo(newPoint);
- // }, 500);
-
}
+ //淇濆瓨瀹氫綅鍧愭爣鐢熸垚杞ㄨ抗
+ var path = [];
+ var lineLayer = new T.Polyline([], { color: '#ff4500', weight: 3, opacity: 0.8 });
+ let locationMarker;
+ function updateInspectionLocation(log, lat) {
+ var lastLat = lat;
+ // const intervalId = setInterval(() => {
+ // lastLat=lastLat+0.0001;
+ var newPoint = new T.LngLat(log, lastLat);
+ path.push(newPoint);
+ lineLayer.setLngLats(path);
+ map.addOverLay(lineLayer);
+ // 绉诲姩鍦板浘瑙嗚鍒版渶鍚庝竴涓綅缃�
+
+ // }, 500);
+ }
+
var aginPath = [];
+ var oldLineLayer = new T.Polyline([], { color: '#ff4500', weight: 3, opacity: 0.8 });
+ //鏄剧ず鍥犲紓甯稿叧闂殑宸℃璁板綍
function aginShowLocation(lng, lat) {
// 璋冪敤 Android 鎻愪緵鐨勬帴鍙o紝鑾峰彇鏁版嵁
- console.log("aginShowLocation>>lng:"+lng+">>>lat:"+lat);
+ console.log("aginShowLocation>>lng:" + lng + ">>>lat:" + lat);
var newPoint = new T.LngLat(lng, lat);
aginPath.push(newPoint);
- lineLayer.setLngLats(aginPath);
- map.addOverLay(lineLayer);
+ oldLineLayer.setLngLats(aginPath);
+ map.addOverLay(oldLineLayer);
+ }
+ //娓呴櫎宸℃璁板綍杞ㄨ抗
+ function cleanLocationLay() {
+ if (lineLayer) {
+ map.removeOverLay(lineLayer);
+ path=[]
+ }
+ if (locationMarker) {
+ map.removeOverLay(locationMarker);
+ }
+ if (oldLineLayer) {
+ aginPath=[]
+ map.removeOverLay(oldLineLayer);
+ }
+ }
+ //娓呴櫎鏈湴瀹氫綅鍧愭爣浣嶇疆
+ function cleanLoclLay(){
+ if (locationMarker) {
+ map.removeOverLay(locationMarker);
+ }
}
--
Gitblit v1.8.0