From 798128053bb17ed293aa8d5424db3b5ed007d375 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期一, 23 十二月 2024 10:20:57 +0800
Subject: [PATCH] 1.优化订单列表框架,升级为viewPager2,提升性能。 2.添加收到新工单后的红点提醒。 3.修复查询数据为空时报错。 4.优化修改经纬度的流程。 5.修复mqtt的CLIENT_ID一致导致的连接错误。 6.修复收到新工单后点击消息通知栏跳转详情时不更新数据的bug。
---
app/src/main/assets/js/map.js | 133 +++++++++++++++++++++++++-------------------
1 files changed, 76 insertions(+), 57 deletions(-)
diff --git a/app/src/main/assets/js/map.js b/app/src/main/assets/js/map.js
index 3b54c66..46dba57 100644
--- a/app/src/main/assets/js/map.js
+++ b/app/src/main/assets/js/map.js
@@ -23,6 +23,8 @@
window.updateInspectionLocation = updateInspectionLocation;
window.cleanLoclLay = cleanLoclLay;
window.showPin = showPin;
+ window.cancelPin = cancelPin;
+ window.refreshMarker = refreshMarker;
}
@@ -34,11 +36,7 @@
mountMethodToWindow();
});
- // window.onload = function () {
- // console.log(window.onload); // 鎵撳嵃鏁扮粍鏁版嵁
- // //鍔犺浇鍧愭爣鐐�
- // window.Android.loadMarker();
- // };
+
// 鍒濆鍖栧湴鍥�
function initMap() {
// 褰卞儚搴曞浘
@@ -146,30 +144,38 @@
// 璋冪敤鍘熺敓瀹夊崜鏂规硶闅愯棌鍙栨按鍙h鎯�
function closeWaterIntakeDetail(data) {
- if (lastClickedMarker !== null) {
- // 濡傛灉鏈夌偣鍑诲彇姘村彛鍒欏皢鍙栨按鍙f仮澶嶆垚榛戣壊
- // 涓婃鐐瑰嚮鐨勬爣娉ㄦ敼涓洪粦鑹�
- var defaulticon = new T.Icon({
- iconUrl: markerBluePath,
- iconSize: new T.Point(28, 28),
- iconAnchor: new T.Point(14, 28)
- });
- lastClickedMarker.setIcon(defaulticon);
+ if (!isShowCenterPin) {
+ if (lastClickedMarker !== null) {
+ // 濡傛灉鏈夌偣鍑诲彇姘村彛鍒欏皢鍙栨按鍙f仮澶嶆垚榛戣壊
+ // 涓婃鐐瑰嚮鐨勬爣娉ㄦ敼涓洪粦鑹�
+ var defaulticon = new T.Icon({
+ iconUrl: markerBluePath,
+ iconSize: new T.Point(28, 28),
+ iconAnchor: new T.Point(14, 28)
+ });
+ lastClickedMarker.setIcon(defaulticon);
+ }
+ if (isShowWaterIntakeDetail) {
+ // 鍋囧鏄剧ず浜嗗彇姘村彛璇︽儏鍒欓殣钘忓彇姘村彛璇︽儏
+ isShowWaterIntakeDetail = false;
+ window.Android.closeWaterIntakeView();
+ } else {
+ // 鍋囧娌℃湁鏄剧ず鍙栨按鍙e垯娣诲姞鐐瑰嚮鐨勫潗鏍�
+ getLngLat(data.lnglat);
+ }
}
- if (isShowWaterIntakeDetail) {
- // 鍋囧鏄剧ず浜嗗彇姘村彛璇︽儏鍒欓殣钘忓彇姘村彛璇︽儏
- isShowWaterIntakeDetail = false;
- window.Android.closeWaterIntakeView();
- } else {
- // 鍋囧娌℃湁鏄剧ず鍙栨按鍙e垯娣诲姞鐐瑰嚮鐨勫潗鏍�
- getLngLat(data.lnglat);
- }
+
}
// 鐐瑰嚮鏍囨敞鐨勪簨浠�
function addMarkerListener(id, data) {
- chageMarkerIcon(data);
- showWaterIntakeDetail(id);
+ if (!isShowCenterPin) {
+ chageMarkerIcon(data);
+ showWaterIntakeDetail(id);
+ }else {
+ showToast("褰撳墠姝e湪淇敼閫変腑鍙栨按鍙g殑缁忕含搴︼紝瀹屾垚鎴栭��鍑哄悗鎵嶅彲閫夋嫨鍏朵粬锛�");
+ }
+
}
// 淇敼鐐瑰嚮鏍囨敞鐨勫浘鏍�
@@ -196,22 +202,32 @@
}
}
lastClickedMarker = data.target;
+ map.panTo(currentMarker.getLngLat());
}
//璋冨畨鍗撳師鐢�
- function showToast() {
+ function showToast(data) {
// 璋冪敤 JavaScript 鎺ュ彛瀵硅薄鐨勬柟娉�
- window.Android.showToast('Hello, Android!');
+ window.Android.showToast(data);
}
// 鍒ゆ柇涓や釜鍧愭爣鏄惁涓�鑷�
function isEqualsLngLat(data1, data2) {
return data1.lat === data2.lat && data1.lng === data2.lng;
}
- //娣诲姞浠庡師鐢熶紶杩囨潵鐨勫潗鏍囧苟鏄剧ず鍦ㄥ湴鍥句笂
function addMarker(id, lng, lat, name) {
- console.log("function銆嬨�嬨�嬨�嬨�媋ddMarker");
+ addMarker(id, lng, lat, name, false)
+ }
+ //娣诲姞浠庡師鐢熶紶杩囨潵鐨勫潗鏍囧苟鏄剧ず鍦ㄥ湴鍥句笂
+ function addMarker(id, lng, lat, name, isRed) {
+ console.log("function銆嬨�嬨�嬨�嬨�媋ddMarker>>>id:" + id);
+ var iconUrl;
+ if (isRed) {
+ iconUrl = markerRedPath;
+ } else {
+ iconUrl = markerBluePath;
+ }
var icon = new T.Icon({
- iconUrl: markerBluePath,
+ iconUrl: iconUrl,
iconSize: new T.Point(28, 28),
iconAnchor: new T.Point(14, 28)
});
@@ -222,7 +238,7 @@
marker.addEventListener("click", (data) => {
addMarkerListener(id, data)
});
- map.addOverLay(marker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓�
+
let label = new T.Label({
text: `<div style='position:absolute;left:-50%;transform: translateX(-50%);'>${name}<div>`,
position: marker.getLngLat(),
@@ -233,8 +249,13 @@
label.setBackgroundColor("transparent"); // 璁剧疆鏂囨湰鐨勮儗鏅壊锛堥�忔槑鑹诧級
label.setFontColor("#FFFFFF");
label.setFontSize(10);
+ marker.label = label;
+ if (isRed){
+ lastClickedMarker=marker;
+ }
map.addOverLay(label);
- return "addMarker鍔犺浇鎴愬姛"
+ map.addOverLay(marker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓�
+ return "addMarker鍔犺浇鎴愬姛 id:" + id
}
//鏇存柊瀹氫綅鍧愭爣
function updateLocation(log, lat) {
@@ -300,36 +321,34 @@
}
}
-
-
- //鍦ㄥ湴鍥句笂鏄剧ず涓績鐐�
- var pinMarker;
- function showPin() {
- var icon = new T.Icon({
- iconUrl: centerPin,
- iconSize: new T.Point(28, 28),
- iconAnchor: new T.Point(14, 28)
- });
- pinMarker = new T.Marker(
- new T.LngLat(map.getCenter().getLng(), map.getCenter().getLat()) // 鍒涘缓鏍囨敞
- , { icon: icon });
- map.addOverLay(pinMarker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓�
- map.addEventListener("moveend", MapMoveend);
+ //鏄惁鏄剧ず浜嗗湴鍥句腑蹇冪殑閽堢敤鏉ヤ慨鏀瑰潗鏍�
+ var isShowCenterPin;
+ //寮�濮嬭幏鍙栧睆骞曚腑闂村畾浣�
+ function showPin(lng, lat) {
+ var newPoint = new T.LngLat(lng, lat);
+ map.panTo(newPoint);
+ isShowCenterPin = true;
+ map.addEventListener("moveend", mapMoveEnd);
+ window.Android.refreshCenter(map.getCenter().getLng(), map.getCenter().getLat());
+ return true;
+ }
+ //鍙栨秷淇敼瀹氫綅
+ function cancelPin() {
+ isShowCenterPin = false;
}
- function MapMoveend(e) {
- map.removeOverLay(pinMarker);
- var icon = new T.Icon({
- iconUrl: centerPin,
- iconSize: new T.Point(28, 28),
- iconAnchor: new T.Point(14, 28)
- });
+ //鎴愬姛淇敼鍙栨按鍙g粡绾害鍚庡埛鏂板彇姘村彛浣嶇疆
+ function refreshMarker(id, lng, lat, name) {
+ map.removeOverLay(lastClickedMarker.label);
+ map.removeOverLay(lastClickedMarker);
+ addMarker(id, lng, lat, name, true);
+ }
+
+
+ function mapMoveEnd(e) {
var center = e.target.getCenter();
console.log("lng:" + center.getLng() + " lat:" + center.getLat())
- pinMarker = new T.Marker(
- new T.LngLat(center.getLng(), center.getLat()) // 鍒涘缓鏍囨敞
- , { icon: icon });
- map.addOverLay(pinMarker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓�
+ window.Android.refreshCenter(center.getLng(), center.getLat());
}
})();
--
Gitblit v1.8.0