From b3e7f379e72111f55a28c302804702ee7c66bfa2 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期六, 18 一月 2025 16:39:16 +0800
Subject: [PATCH] 1.管网的js相关代码
---
app/src/main/java/com/dayu/pipirrapp/bean/db/PipeNetworkBean.java | 103 ++++++
settings.gradle | 2
app/src/main/assets/js/map.js | 258 ++++++++++++++-
expand_button/src/main/AndroidManifest.xml | 4
expand_button/src/test/java/com/example/expand_button/ExampleUnitTest.kt | 17 +
app/src/main/java/com/dayu/pipirrapp/tool/MyWebViewInterface.java | 20 +
expand_button/.gitignore | 1
expand_button/consumer-rules.pro | 0
expand_button/src/androidTest/java/com/example/expand_button/ExampleInstrumentedTest.kt | 24 +
app/src/main/java/com/dayu/pipirrapp/bean/db/DivideBean.java | 6
app/src/main/res/layout/fragment_map.xml | 55 +++
app/src/main/java/com/dayu/pipirrapp/bean/net/PipeNetworkResult.java | 92 +++++
app/src/main/java/com/dayu/pipirrapp/bean/net/DivideResult.java | 39 +
expand_button/build.gradle | 41 ++
expand_button/src/main/java/com/example/expand_button/ExpandButton.kt | 14
app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java | 195 +++++++++++
app/src/main/java/com/dayu/pipirrapp/bean/net/PipeNetworkListResult.java | 58 +++
expand_button/proguard-rules.pro | 21 +
18 files changed, 896 insertions(+), 54 deletions(-)
diff --git a/app/src/main/assets/js/map.js b/app/src/main/assets/js/map.js
index a13de46..8238d7f 100644
--- a/app/src/main/assets/js/map.js
+++ b/app/src/main/assets/js/map.js
@@ -4,9 +4,11 @@
IMAGES: {
LOCATION: 'img/location.png',
MARKER_BLACK: 'img/marker_black.svg',
- MARKER_RED: 'img/marker_red.svg',
+ MARKER_RED: 'img/marker_red.svg',
MARKER_BLUE: 'img/marker_blue.svg',
- CENTER_PIN: 'img/push_pin.svg'
+ CENTER_PIN: 'img/push_pin.svg',
+ DIVIDE_BLUE: 'img/divide_home_blue.svg',
+ DIVIDE_RED: 'img/divide_home_red.svg'
},
MAP: {
DEFAULT_ZOOM: 12,
@@ -16,8 +18,14 @@
let map;
let lastMarker = null;
let lastClickedMarker = null;
+ let lastClickedDivide = null;
let isShowWaterIntakeDetail = false;
+ let isShowDivideDetail = false;
let zoom = 12;
+
+ // 瀛樺偍鎵�鏈夌缃戠嚎璺殑鏁扮粍
+ let pipeLineList = [];
+ let currentPipePath = [];
// 灏嗘柟娉曟寕杞藉埌 window 涓�
function mountMethodToWindow() {
@@ -33,7 +41,11 @@
window.showPin = showPin;
window.cancelPin = cancelPin;
window.refreshMarker = refreshMarker;
-
+ window.addDivide = addDivide;
+ window.showAllPipeLines = showAllPipeLines;
+ window.hideAllPipeLines = hideAllPipeLines;
+ window.clearAllPipeLines = clearAllPipeLines;
+ window.addPipeNetwork = addPipeNetwork;
}
@@ -129,7 +141,7 @@
iconAnchor: new T.Point(10, 10)
});
let marker = new T.Marker(
- new T.LngLat(lng, lag),
+ new T.LngLat(lng, lag),
{ icon: icon }
);
map.addOverLay(marker);
@@ -158,7 +170,7 @@
if (lastClickedMarker !== null) {
lastClickedMarker.setIcon(createIcon(CONFIG.IMAGES.MARKER_BLUE));
}
- if (isShowWaterIntakeDetail) {
+ if (isShowWaterIntakeDetail || isShowDivideDetail) {
// 鍋囧鏄剧ず浜嗗彇姘村彛璇︽儏鍒欓殣钘忓彇姘村彛璇︽儏
isShowWaterIntakeDetail = false;
window.Android.closeWaterIntakeView();
@@ -167,7 +179,6 @@
getLngLat(data.lnglat);
}
}
-
}
// 鐐瑰嚮鏍囨敞鐨勪簨浠�
@@ -175,7 +186,7 @@
if (!isShowCenterPin) {
chageMarkerIcon(data);
showWaterIntakeDetail(id);
- }else {
+ } else {
showToast("褰撳墠姝e湪淇敼閫変腑鍙栨按鍙g殑缁忕含搴︼紝瀹屾垚鎴栭��鍑哄悗鎵嶅彲閫夋嫨鍏朵粬锛�");
}
@@ -186,11 +197,14 @@
// 鐐瑰嚮鐨勬爣娉ㄦ敼涓虹孩鑹�
var currentMarker = data.target;
currentMarker.setIcon(createIcon(CONFIG.IMAGES.MARKER_RED));
-
+
if (lastClickedMarker !== null) {
if (!isEqualsLngLat(data.target.getLngLat(), lastClickedMarker.getLngLat())) {
lastClickedMarker.setIcon(createIcon(CONFIG.IMAGES.MARKER_BLUE));
}
+ }
+ if (lastClickedDivide !== null) {
+ lastClickedDivide.setIcon(createIcon(CONFIG.IMAGES.MARKER_BLUE));
}
lastClickedMarker = data.target;
map.panTo(currentMarker.getLngLat());
@@ -232,8 +246,8 @@
label.setFontColor("#FFFFFF");
label.setFontSize(10);
marker.label = label;
- if (isRed){
- lastClickedMarker=marker;
+ if (isRed) {
+ lastClickedMarker = marker;
}
map.addOverLay(label);
map.addOverLay(marker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓�
@@ -250,9 +264,9 @@
iconSize: new T.Point(20, 20),
iconAnchor: new T.Point(10, 10)
});
-
+
locationMarker = new T.Marker(
- newPoint,
+ newPoint,
{ icon: icon }
);
map.addOverLay(locationMarker);
@@ -264,15 +278,144 @@
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 pipePath = [];
+ var pipeLineLayer = new T.Polyline([], { color: '#E9900A', weight: 3, opacity: 0.8 });
+
+ // 绠$綉绾胯矾绠$悊
+ const PipelineManager = {
+ lines: [], // 瀛樺偍鎵�鏈夊畬鎴愮殑绾胯矾
+ currentLine: {
+ points: [], // 褰撳墠绾胯矾鐨勭偣
+ overlay: null // 褰撳墠绾胯矾鐨勫浘灞傚璞�
+ },
+
+ // 绾胯矾鏍峰紡閰嶇疆
+ style: {
+ color: '#1890FF',
+ weight: 3,
+ opacity: 0.8
+ },
+
+ /**
+ * 娣诲姞鐐瑰埌绠$綉绾胯矾
+ * @param {number} lng 缁忓害
+ * @param {number} lat 绾害
+ * @param {boolean} isNewLine 鏄惁寮�濮嬫柊鐨勭嚎璺�
+ */
+ addPoint(lng, lat, isNewLine) {
+ if (isNewLine) {
+ this.finishCurrentLine();
+ }
+
+ const point = new T.LngLat(lng, lat);
+ this.currentLine.points.push(point);
+
+ if (this.currentLine.points.length > 1) {
+ this.updateCurrentLineDisplay();
+ }
+ },
+
+ /**
+ * 鏇存柊褰撳墠绾胯矾鐨勬樉绀�
+ */
+ updateCurrentLineDisplay() {
+ if (!this.currentLine.overlay) {
+ // 鍒涘缓鏂扮殑绾胯矾鍥惧眰
+ this.currentLine.overlay = new T.Polyline(this.currentLine.points, this.style);
+ map.addOverLay(this.currentLine.overlay);
+ } else {
+ // 鏇存柊鐜版湁绾胯矾鐨勭偣
+ this.currentLine.overlay.setLngLats(this.currentLine.points);
+ }
+ },
+
+ /**
+ * 瀹屾垚褰撳墠绾胯矾
+ */
+ finishCurrentLine() {
+ if (this.currentLine.points.length > 1) {
+ if (this.currentLine.overlay) {
+ // 灏嗗綋鍓嶇嚎璺坊鍔犲埌瀹屾垚鍒楄〃
+ this.lines.push(this.currentLine.overlay);
+ }
+ } else if (this.currentLine.overlay) {
+ // 濡傛灉鐐规暟涓嶈冻锛屾竻闄ゅ浘灞�
+ map.removeOverLay(this.currentLine.overlay);
+ }
+
+ // 閲嶇疆褰撳墠绾胯矾
+ this.currentLine = {
+ points: [],
+ overlay: null
+ };
+ },
+
+ /**
+ * 鏄剧ず鎵�鏈夌嚎璺�
+ */
+ showAll() {
+ this.lines.forEach(line => map.addOverLay(line));
+ if (this.currentLine.overlay) {
+ map.addOverLay(this.currentLine.overlay);
+ }
+ },
+
+ /**
+ * 闅愯棌鎵�鏈夌嚎璺�
+ */
+ hideAll() {
+ this.lines.forEach(line => map.removeOverLay(line));
+ if (this.currentLine.overlay) {
+ map.removeOverLay(this.currentLine.overlay);
+ }
+ },
+
+ /**
+ * 娓呴櫎鎵�鏈夌嚎璺�
+ */
+ clearAll() {
+ this.hideAll();
+ this.lines = [];
+ this.currentLine = {
+ points: [],
+ overlay: null
+ };
+ }
+ };
+
+ /**
+ * 娣诲姞绠$綉绾胯矾鐐�
+ */
+ function addPipeNetwork(lng, lat, isNewLine) {
+ PipelineManager.addPoint(lng, lat, isNewLine);
+ }
+
+ /**
+ * 鏄剧ず鎵�鏈夌缃戠嚎璺�
+ */
+ function showAllPipeLines() {
+ PipelineManager.showAll();
+ }
+
+ /**
+ * 闅愯棌鎵�鏈夌缃戠嚎璺�
+ */
+ function hideAllPipeLines() {
+ PipelineManager.hideAll();
+ }
+
+ /**
+ * 娓呴櫎鎵�鏈夌缃戠嚎璺�
+ */
+ function clearAllPipeLines() {
+ PipelineManager.clearAll();
}
var aginPath = [];
@@ -316,7 +459,7 @@
isShowCenterPin = true;
map.addEventListener("moveend", mapMoveEnd);
window.Android.refreshCenter(map.getCenter().getLng(), map.getCenter().getLat());
- return true;
+ return true;
}
//鍙栨秷淇敼瀹氫綅
function cancelPin() {
@@ -341,8 +484,8 @@
// 娣诲姞闃叉姈鍑芥暟
function debounce(fn, delay) {
let timer = null;
- return function() {
- if(timer) clearTimeout(timer);
+ return function () {
+ if (timer) clearTimeout(timer);
timer = setTimeout(() => {
fn.apply(this, arguments);
}, delay);
@@ -356,8 +499,83 @@
return new T.Icon({
iconUrl: iconUrl,
iconSize: new T.Point(size, size),
- iconAnchor: new T.Point(size/2, size)
+ iconAnchor: new T.Point(size / 2, size)
});
}
+ //娣诲姞鍒嗘按鎴�
+ function addDivide(id, lng, lat, name) {
+ addDivide(id, lng, lat, name, false)
+ }
+ //娣诲姞鍒嗘按鎴�
+ function addDivide(id, lng, lat, name, isRed) {
+ console.log("function銆嬨�嬨�嬨�嬨�媋ddMarker>>>id:" + id);
+
+ const iconUrl = isRed ? CONFIG.IMAGES.DIVIDE_RED : CONFIG.IMAGES.DIVIDE_BLUE;
+ let marker = new T.Marker(
+ new T.LngLat(lng, lat),
+ { icon: createIcon(iconUrl) }
+ );
+ //娣诲姞鐐瑰嚮浜嬩欢
+ marker.addEventListener("click", (data) => {
+ addDivideListener(id, data)
+ });
+
+ let label = new T.Label({
+ text: `<div style='position:absolute;left:-50%;transform: translateX(-50%);'>${name}<div>`,
+ position: marker.getLngLat(),
+ offset: new T.Point(0, 8), // 璁剧疆鏍囨敞鏂囧瓧鐨勪綅缃�
+ opacity: 1, // 璁剧疆鏂囨湰鐨勬樉绀轰笉閫忔槑搴︼紙鑼冨洿0-1锛�
+ });
+ label.setBorderLine(0); // 璁剧疆鏂囨湰鐨勮竟妗嗙嚎瀹�
+ label.setBackgroundColor("transparent"); // 璁剧疆鏂囨湰鐨勮儗鏅壊锛堥�忔槑鑹诧級
+ label.setFontColor("#FFFFFF");
+ label.setFontSize(10);
+ marker.label = label;
+ if (isRed) {
+ lastClickedMarker = marker;
+ }
+ map.addOverLay(label);
+ map.addOverLay(marker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓�
+ return "addMarker鍔犺浇鎴愬姛 id:" + id
+ }
+ // 淇敼鐐瑰嚮鏍囨敞鐨勫浘鏍�
+ function chageDivideIcon(data) {
+ // 鐐瑰嚮鐨勬爣娉ㄦ敼涓虹孩鑹�
+ var currentMarker = data.target;
+ currentMarker.setIcon(createIcon(CONFIG.IMAGES.DIVIDE_RED));
+
+ if (lastClickedDivide !== null) {
+ if (!isEqualsLngLat(data.target.getLngLat(), lastClickedDivide.getLngLat())) {
+ lastClickedDivide.setIcon(createIcon(CONFIG.IMAGES.DIVIDE_BLUE));
+ }
+ }
+ if (lastClickedMarker !== null) {
+ lastClickedMarker.setIcon(createIcon(CONFIG.IMAGES.MARKER_BLUE));
+ }
+ lastClickedDivide = data.target;
+ map.panTo(currentMarker.getLngLat());
+ }
+
+ // 鐐瑰嚮鏍囨敞鐨勪簨浠�
+ function addDivideListener(id, data) {
+ // if (!isShowCenterPin) {
+ chageDivideIcon(data);
+ showDivideDetail(id);
+ // } else {
+ // showToast("褰撳墠姝e湪淇敼閫変腑鍙栨按鍙g殑缁忕含搴︼紝瀹屾垚鎴栭��鍑哄悗鎵嶅彲閫夋嫨鍏朵粬锛�");
+ // }
+
+ }
+
+ // 璋冪敤鍘熺敓瀹夊崜鏂规硶鏄剧ず鍙栨按鍙h鎯�
+ function showDivideDetail(data) {
+ isShowDivideDetail = true;
+ window.Android.showDivideDetail(data);
+ }
+
+
+
+
+
})();
diff --git a/app/src/main/java/com/dayu/pipirrapp/bean/db/DivideBean.java b/app/src/main/java/com/dayu/pipirrapp/bean/db/DivideBean.java
index 46f24f6..2b7fa4b 100644
--- a/app/src/main/java/com/dayu/pipirrapp/bean/db/DivideBean.java
+++ b/app/src/main/java/com/dayu/pipirrapp/bean/db/DivideBean.java
@@ -87,7 +87,7 @@
/**
* 瑕嗙洊闈㈢Н
*/
- private double area;
+ private String area;
// Getters and Setters
@@ -99,11 +99,11 @@
this.address = address;
}
- public double getArea() {
+ public String getArea() {
return area;
}
- public void setArea(double area) {
+ public void setArea(String area) {
this.area = area;
}
diff --git a/app/src/main/java/com/dayu/pipirrapp/bean/db/PipeNetworkBean.java b/app/src/main/java/com/dayu/pipirrapp/bean/db/PipeNetworkBean.java
new file mode 100644
index 0000000..8dbcf2b
--- /dev/null
+++ b/app/src/main/java/com/dayu/pipirrapp/bean/db/PipeNetworkBean.java
@@ -0,0 +1,103 @@
+package com.dayu.pipirrapp.bean.db;
+
+import androidx.room.Entity;
+import androidx.room.PrimaryKey;
+
+import com.dayu.pipirrapp.bean.net.PipeNetworkResult;
+
+import java.util.List;
+
+/**
+ * PipeNetworkBean -
+ *
+ * @author zuoxiao
+ * @version 1.0
+ * @since 2025-01-17
+ */
+@Entity
+public class PipeNetworkBean {
+ @PrimaryKey(autoGenerate = true)
+ public long id;
+
+ String type;
+ String networkId;
+ List<PipeNetworkResult.Data> data;
+
+
+ public class Data {
+ public class Coordinate {
+ String lat;
+ String lng;
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+ }
+
+ List<PipeNetworkResult.Data.Coordinate> coordinates;
+ String type;
+ String networkId;
+
+ public List<PipeNetworkResult.Data.Coordinate> getCoordinates() {
+ return coordinates;
+ }
+
+ public void setCoordinates(List<PipeNetworkResult.Data.Coordinate> coordinates) {
+ this.coordinates = coordinates;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+
+ public List<PipeNetworkResult.Data> getData() {
+ return data;
+ }
+
+ public void setData(List<PipeNetworkResult.Data> data) {
+ this.data = data;
+ }
+
+
+}
diff --git a/app/src/main/java/com/dayu/pipirrapp/bean/net/DivideResult.java b/app/src/main/java/com/dayu/pipirrapp/bean/net/DivideResult.java
index 960bcf3..b28d76c 100644
--- a/app/src/main/java/com/dayu/pipirrapp/bean/net/DivideResult.java
+++ b/app/src/main/java/com/dayu/pipirrapp/bean/net/DivideResult.java
@@ -29,9 +29,14 @@
private String divideId;
/**
- * 鍒嗘按鎴垮悕绉�
+ * 鍒嗘按鎴垮悕绉�(鍒楄〃鎺ュ彛杩斿洖)
*/
private String divideName;
+
+ /**
+ * 鍒嗘按鎴垮悕绉�(璇︽儏鎺ュ彛杩斿洖)
+ */
+ private String name;
/**
* 璐熻矗浜�
@@ -41,17 +46,17 @@
/**
* 缂栧彿
*/
- private int id;
+ private String id;
/**
* 绾害
*/
- private double lat;
+ private String lat;
/**
* 缁忓害
*/
- private double lng;
+ private String lng;
/**
* 鎿嶄綔鏃堕棿
@@ -81,8 +86,15 @@
/**
* 瑕嗙洊闈㈢Н
*/
- private double area;
+ private String area;
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
// Getters and Setters
public String getAddress() {
@@ -93,11 +105,11 @@
this.address = address;
}
- public double getArea() {
+ public String getArea() {
return area;
}
- public void setArea(double area) {
+ public void setArea(String area) {
this.area = area;
}
@@ -141,27 +153,28 @@
this.header = header;
}
- public int getId() {
+
+ public String getId() {
return id;
}
- public void setId(int id) {
+ public void setId(String id) {
this.id = id;
}
- public double getLat() {
+ public String getLat() {
return lat;
}
- public void setLat(double lat) {
+ public void setLat(String lat) {
this.lat = lat;
}
- public double getLng() {
+ public String getLng() {
return lng;
}
- public void setLng(double lng) {
+ public void setLng(String lng) {
this.lng = lng;
}
diff --git a/app/src/main/java/com/dayu/pipirrapp/bean/net/PipeNetworkListResult.java b/app/src/main/java/com/dayu/pipirrapp/bean/net/PipeNetworkListResult.java
new file mode 100644
index 0000000..9f97df4
--- /dev/null
+++ b/app/src/main/java/com/dayu/pipirrapp/bean/net/PipeNetworkListResult.java
@@ -0,0 +1,58 @@
+package com.dayu.pipirrapp.bean.net;
+
+import java.util.List;
+
+/**
+ * PipeNetworkListResult -
+ *
+ * @author zuoxiao
+ * @version 1.0
+ * @since 2025-01-17
+ */
+public class PipeNetworkListResult {
+ int itemTotal;
+ int pageCurr;
+ int pageSize;
+ int pageTotal;
+ List<PipeNetworkResult> obj;
+
+ public int getItemTotal() {
+ return itemTotal;
+ }
+
+ public void setItemTotal(int itemTotal) {
+ this.itemTotal = itemTotal;
+ }
+
+ public int getPageCurr() {
+ return pageCurr;
+ }
+
+ public void setPageCurr(int pageCurr) {
+ this.pageCurr = pageCurr;
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ public int getPageTotal() {
+ return pageTotal;
+ }
+
+ public void setPageTotal(int pageTotal) {
+ this.pageTotal = pageTotal;
+ }
+
+ public List<PipeNetworkResult> getObj() {
+ return obj;
+ }
+
+ public void setObj(List<PipeNetworkResult> obj) {
+ this.obj = obj;
+ }
+}
diff --git a/app/src/main/java/com/dayu/pipirrapp/bean/net/PipeNetworkResult.java b/app/src/main/java/com/dayu/pipirrapp/bean/net/PipeNetworkResult.java
new file mode 100644
index 0000000..01105ef
--- /dev/null
+++ b/app/src/main/java/com/dayu/pipirrapp/bean/net/PipeNetworkResult.java
@@ -0,0 +1,92 @@
+package com.dayu.pipirrapp.bean.net;
+
+import java.util.List;
+
+/**
+ * PipeNetworkResult - 绠$綉瀹炰緥
+ *
+ * @author zuoxiao
+ * @version 1.0
+ * @since 2025-01-17
+ */
+public class PipeNetworkResult {
+ String type;
+ String networkId;
+ List<Data> data;
+
+
+ public class Data {
+ public class Coordinate {
+ String lat;
+ String lng;
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+ }
+
+ List<Coordinate> coordinates;
+ String type;
+ String networkId;
+
+ public List<Coordinate> getCoordinates() {
+ return coordinates;
+ }
+
+ public void setCoordinates(List<Coordinate> coordinates) {
+ this.coordinates = coordinates;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+
+ public List<Data> getData() {
+ return data;
+ }
+
+ public void setData(List<Data> data) {
+ this.data = data;
+ }
+}
diff --git a/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java b/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java
index addff5b..c414864 100644
--- a/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java
+++ b/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java
@@ -31,6 +31,7 @@
import com.dayu.pipirrapp.bean.db.InspectionLocationBean;
import com.dayu.pipirrapp.bean.db.LatLonBean;
import com.dayu.pipirrapp.bean.db.MarkerBean;
+import com.dayu.pipirrapp.bean.db.PipeNetworkBean;
import com.dayu.pipirrapp.bean.net.CenterPointResult;
import com.dayu.pipirrapp.bean.net.DivideListResult;
import com.dayu.pipirrapp.bean.net.DivideResult;
@@ -38,6 +39,8 @@
import com.dayu.pipirrapp.bean.net.InspectionRequest;
import com.dayu.pipirrapp.bean.net.MarkerListResult;
import com.dayu.pipirrapp.bean.net.MarkerResult;
+import com.dayu.pipirrapp.bean.net.PipeNetworkListResult;
+import com.dayu.pipirrapp.bean.net.PipeNetworkResult;
import com.dayu.pipirrapp.dao.DaoSingleton;
import com.dayu.pipirrapp.databinding.FragmentMapBinding;
import com.dayu.pipirrapp.net.ApiManager;
@@ -148,7 +151,9 @@
getCenterPoint();
initView();
initWeb();
+
getMarkerData();
+ getDivideList();
chageInspecState(mInspectionState);
return binding.getRoot();
@@ -213,7 +218,7 @@
super.onPageFinished(view, url);
//椤甸潰鍔犺浇瀹屾垚
webViewIsFinished = true;
- initLocalData();
+ webFinishInitLocalData();
aginShowLocation(null);
}
@@ -221,9 +226,9 @@
}
/**
- * 鍒濆鍖栨湰鍦版暟鎹�
+ * web鍔犺浇瀹屽垵濮嬪寲鏈湴鏁版嵁
*/
- public void initLocalData() {
+ public void webFinishInitLocalData() {
//璺宠浆涓績鐐�
centerPointBean = DaoSingleton.getInstance(MapFragment.this.getContext()).centerPointDao().findFirst();
jumpCenterPoint();
@@ -231,6 +236,11 @@
if (!webNoFinishMarkerData.isEmpty()) {
for (MarkerBean bean : webNoFinishMarkerData) {
setMapMarker(bean);
+ }
+ }
+ if (!webNoFinishDivideData.isEmpty()) {
+ for (DivideBean bean : webNoFinishDivideData) {
+ setMapDivide(bean);
}
}
//鏄剧ず鎵�鏈夊彇姘村彛
@@ -252,9 +262,7 @@
@Override
public void onNext(BaseResponse<MarkerListResult> t) {
if (t.isSuccess()) {
-
if (t.getContent().getObj() != null && !t.getContent().getObj().isEmpty()) {
-
List<MarkerBean> markerBeans = t.getContent().getObj().stream()
.map(result -> {
MarkerBean markerBean = new MarkerBean();
@@ -349,6 +357,20 @@
}
+ /**
+ * 鏄剧ず鍒嗘按鎴胯鎯�
+ *
+ * @param data
+ */
+ public void showDivideDetail(String data) {
+ MyLog.i(data);
+ DivideBean markerBean = divideBeanMap.get(data);
+ if (markerBean != null) {
+ binding.bottomLL.setVisibility(View.GONE);
+ getDivideDetail(markerBean);
+ }
+
+ }
/**
* 鑾峰彇鍦板浘涓績鐐�
@@ -581,18 +603,18 @@
/**
* 娣诲姞鍙栨按鍙f爣娉�
*/
- public void setDivide(DivideBean divide) {
+ public void setMapDivide(DivideBean divide) {
if (divide != null) {
if (webViewIsFinished) {
if (!TextUtils.isEmpty(divide.getLng()) && !TextUtils.isEmpty(divide.getLat())) {
- mWebView.evaluateJavascript("javascript:addMarker(\"" + divide.getId() + "\",\"" + divide.getLng() + "\",\"" + divide.getLat() + "\",\"" + divide.getDivideName() + "\")", new ValueCallback<String>() {
+ mWebView.evaluateJavascript("javascript:addDivide(\"" + divide.getId() + "\",\"" + divide.getLng() + "\",\"" + divide.getLat() + "\",\"" + divide.getDivideName() + "\")", new ValueCallback<String>() {
@Override
public void onReceiveValue(String value) {
}
});
divideBeanMap.put(divide.getId(), divide);
} else {
- MyLog.d("setMapMarker>" + divide.getDivideName() + "缁忕含搴︿负绌�");
+ MyLog.d("setMapDivide>" + divide.getDivideName() + "缁忕含搴︿负绌�");
}
} else {
webNoFinishDivideData.add(divide);
@@ -600,6 +622,28 @@
}
}
+ /**
+ * 娣诲姞鍙栨按鍙f爣娉�
+ */
+ public void setMapDivide(PipeNetworkBean pipeNetworkBean) {
+// if (divide != null) {
+// if (webViewIsFinished) {
+// for ()
+// if (!TextUtils.isEmpty(divide.getLng()) && !TextUtils.isEmpty(divide.getLat())) {
+// mWebView.evaluateJavascript("javascript:addDivide(\"" + divide.getId() + "\",\"" + divide.getLng() + "\",\"" + divide.getLat() + "\",\"" + divide.getDivideName() + "\")", new ValueCallback<String>() {
+// @Override
+// public void onReceiveValue(String value) {
+// }
+// });
+// divideBeanMap.put(divide.getId(), divide);
+// } else {
+// MyLog.d("setMapDivide>" + divide.getDivideName() + "缁忕含搴︿负绌�");
+// }
+// } else {
+// webNoFinishDivideData.add(divide);
+// }
+// }
+ }
/**
* 寮�濮嬪贰妫�鐨勭浉鍏抽�昏緫
@@ -748,8 +792,32 @@
});
}
+ /**
+ * 鏄剧ず鍙栨按鍙h鎯�
+ */
+ private void getDivideDetail(DivideBean divideBean) {
+ ApiManager.getInstance().requestGet(this.getContext(), Constants.BASE_URL + "/project/divide/getone/" + divideBean.getDivideId(), DivideResult.class, null, new SubscriberListener<BaseResponse<DivideResult>>() {
+ @Override
+ public void onNext(BaseResponse<DivideResult> t) {
+ if (t.isSuccess()) {
+ DivideBean divideBean = getDivideBean(t.getContent());
+ showDivideMarker(divideBean);
+ } else {
+ ToastUtil.showToast(MapFragment.this.getContext(), t.getMsg());
+ }
+ }
+
+ });
+ }
+
+ /**
+ * 鏄剧ず鍙栨按鍙h鎯�
+ */
private void showMarker(MarkerBean markerBean) {
binding.bottomLL.setVisibility(View.VISIBLE);
+ binding.phoneLL.setVisibility(View.GONE);
+ binding.headerLL.setVisibility(View.GONE);
+ binding.editePoint.setVisibility(View.VISIBLE);
binding.markerAddress.setText(markerBean.getAddress());
binding.markerName.setText(markerBean.getName());
binding.markerBlockName.setText(markerBean.getBlockName());
@@ -785,23 +853,112 @@
}
/**
+ * 鏄剧ず鍒嗘按鎴胯鎯�
+ *
+ * @param divideBean
+ */
+ private void showDivideMarker(DivideBean divideBean) {
+ binding.bottomLL.setVisibility(View.VISIBLE);
+ binding.phoneLL.setVisibility(View.VISIBLE);
+ binding.headerLL.setVisibility(View.VISIBLE);
+ binding.editePoint.setVisibility(View.GONE);
+ binding.markerAddress.setText(divideBean.getAddress());
+ binding.markerName.setText(divideBean.getDivideName());
+ binding.markerBlockName.setText(divideBean.getBlockName());
+ binding.phone.setText(divideBean.getPhone());
+ binding.header.setText(divideBean.getHeader());
+ binding.lat.setText(divideBean.getLat());
+ binding.lng.setText(divideBean.getLng());
+ //淇敼缁忕含搴�
+ binding.editePoint.setOnClickListener(v -> {
+
+ mWebView.evaluateJavascript("javascript:showPin(\"" + divideBean.getLng() + "\",\"" + divideBean.getLat() + "\")", value -> {
+ binding.pointRL.setVisibility(View.VISIBLE);
+ binding.pointCenterImg.setVisibility(View.VISIBLE);
+ MyLog.d("showPin>>" + value);
+ });
+
+ });
+ //鍙栨秷淇敼缁忕含搴�
+ binding.pointCancel.setOnClickListener(v -> {
+ binding.pointCenterImg.setVisibility(View.GONE);
+ binding.pointRL.setVisibility(View.GONE);
+ mWebView.evaluateJavascript("javascript:cancelPin()", value -> {
+
+ });
+ }
+ );
+ //纭淇敼缁忕含搴�
+ binding.pointEdt.setOnClickListener(v -> {
+ ConfirmDialog confirmDialog = new ConfirmDialog(MapFragment.this.getActivity(), "纭淇敼鍒拌浣嶇疆鍚楋紵", (confirmDialog1, v1) -> {
+ confirmDialog1.dismiss();
+// updataInstake(markerBean);
+ });
+ confirmDialog.show();
+ });
+ }
+
+
+ /**
* 鑾峰彇鍒嗘按鎴�
*/
private void getDivideList() {
- ApiManager.getInstance().requestPost(MapFragment.this.getContext(), BASE_URL + "/project/divide/getDivides", DivideListResult.class, null, new SubscriberListener<BaseResponse<DivideListResult>>() {
+ ApiManager.getInstance().requestGetHideLoading(MapFragment.this.getContext(), BASE_URL + "/project/divide/getDivides", DivideListResult.class, null, new SubscriberListener<BaseResponse<DivideListResult>>() {
@Override
public void onNext(BaseResponse<DivideListResult> t) {
try {
if (t.isSuccess()) {
- if (t.getContent().getObj() != null && t.getContent().getObj().isEmpty()) {
+ if (t.getContent().getObj() != null && !t.getContent().getObj().isEmpty()) {
List<DivideBean> divideBeans = new ArrayList<>();
for (DivideResult divideResult : t.getContent().getObj()) {
DivideBean divideBean = getDivideBean(divideResult);
+ setMapDivide(divideBean);
divideBeans.add(divideBean);
}
+ // 浣跨敤 RxJava 寮傛鎻掑叆鏁版嵁
+ DaoSingleton.getAsynchInstance(MapFragment.this.getContext()).divideDao().insertAll(divideBeans)
+ .subscribeOn(Schedulers.io()) // 鍦� IO 绾跨▼涓婃墽琛�
+ .observeOn(AndroidSchedulers.mainThread()) // 鍦ㄤ富绾跨▼涓婅瀵�
+ .subscribe(() -> {
+ // 鎻掑叆鎴愬姛
+ Log.i("mWebView", "鏁版嵁鎻掑叆鎴愬姛");
+ }, throwable -> {
+ // 鎻掑叆澶辫触
+ Log.e("mWebView", "鏁版嵁鎻掑叆澶辫触: " + throwable.getMessage());
+ });
+ }
+ } else {
+ ToastUtil.showToastLong(MapFragment.this.getContext(), t.getMsg());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ CrashReport.postCatchedException(e);
+ }
+ }
+
+ });
+ }
+
+ /**
+ * 鑾峰彇绠$綉
+ */
+ private void getPipeNetworkList() {
+ ApiManager.getInstance().requestGetHideLoading(MapFragment.this.getContext(), BASE_URL + "/project/network/all", PipeNetworkListResult.class, null, new SubscriberListener<BaseResponse<PipeNetworkListResult>>() {
+ @Override
+ public void onNext(BaseResponse<PipeNetworkListResult> t) {
+ try {
+ if (t.isSuccess()) {
+ if (t.getContent().getObj() != null && !t.getContent().getObj().isEmpty()) {
+
+ List<DivideBean> divideBeans = new ArrayList<>();
+ for (PipeNetworkResult divideResult : t.getContent().getObj()) {
+ PipeNetworkBean divideBean = getPipeNetworkBean(divideResult);
+ setMapDivide(divideBean);
+// divideBeans.add(divideBean);
+ }
// 浣跨敤 RxJava 寮傛鎻掑叆鏁版嵁
DaoSingleton.getAsynchInstance(MapFragment.this.getContext()).divideDao().insertAll(divideBeans)
.subscribeOn(Schedulers.io()) // 鍦� IO 绾跨▼涓婃墽琛�
@@ -838,11 +995,16 @@
divideBean.setBlockId(divideResult.getBlockId());
divideBean.setBlockName(divideResult.getBlockName());
divideBean.setDivideId(divideResult.getDivideId());
- divideBean.setDivideName(divideResult.getDivideName());
+ if (!TextUtils.isEmpty(divideResult.getDivideName())) {
+ divideBean.setDivideName(divideResult.getDivideName());
+ } else {
+ divideBean.setDivideName(divideResult.getName());
+ }
+
divideBean.setHeader(divideResult.getHeader());
- divideBean.setId(String.valueOf(divideResult.getId()));
- divideBean.setLat(String.valueOf(divideResult.getLat()));
- divideBean.setLng(String.valueOf(divideResult.getLng()));
+ divideBean.setId(divideResult.getId());
+ divideBean.setLat(divideResult.getLat());
+ divideBean.setLng(divideResult.getLng());
divideBean.setOperateDt(divideResult.getOperateDt());
divideBean.setOperator(divideResult.getOperator());
divideBean.setPhone(divideResult.getPhone());
@@ -852,6 +1014,11 @@
return divideBean;
}
+ private static @NonNull PipeNetworkBean getPipeNetworkBean(PipeNetworkResult divideResult) {
+ PipeNetworkBean pipeNetworkBean = new PipeNetworkBean();
+
+ return pipeNetworkBean;
+ }
@Override
public void onDestroy() {
diff --git a/app/src/main/java/com/dayu/pipirrapp/tool/MyWebViewInterface.java b/app/src/main/java/com/dayu/pipirrapp/tool/MyWebViewInterface.java
index fb6fd97..4370624 100644
--- a/app/src/main/java/com/dayu/pipirrapp/tool/MyWebViewInterface.java
+++ b/app/src/main/java/com/dayu/pipirrapp/tool/MyWebViewInterface.java
@@ -43,7 +43,6 @@
myContext.showWaterIntakeDetail(data);
}
});
-
}
}
@@ -98,4 +97,23 @@
});
}
}
+
+ /**
+ * 鏄剧ず鍒嗘按鎴胯鎯�
+ * @param id
+ */
+ @JavascriptInterface
+ public void showDivideDetail(String id){
+ if (myContext instanceof MapFragment) {
+ new Handler(Looper.getMainLooper()).post(new Runnable() {
+ @Override
+ public void run() {
+ // 鍦ㄤ富绾跨▼涓婃墽琛孶I鎿嶄綔
+ // 鏇存柊鎴栨搷浣淯I鍏冪礌鐨勪唬鐮�
+ myContext.showDivideDetail(id);
+
+ }
+ });
+ }
+ }
}
diff --git a/app/src/main/res/layout/fragment_map.xml b/app/src/main/res/layout/fragment_map.xml
index a897113..715b846 100644
--- a/app/src/main/res/layout/fragment_map.xml
+++ b/app/src/main/res/layout/fragment_map.xml
@@ -11,8 +11,7 @@
<RelativeLayout
android:id="@+id/webViewRL"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- >
+ android:layout_height="match_parent">
<WebView
@@ -272,6 +271,57 @@
android:src="@drawable/ic_edit_btn" />
</LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/headerLL"
+ android:layout_width="match_parent"
+ android:layout_height="25dp"
+ android:gravity="center"
+ android:orientation="horizontal">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="璐熻矗浜猴細"
+ android:textColor="@color/black"
+ android:textSize="@dimen/common_text_size_little" />
+
+ <TextView
+ android:id="@+id/header"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:text=""
+ android:textColor="@color/black"
+ android:textSize="@dimen/common_text_size_little" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/phoneLL"
+ android:layout_width="match_parent"
+ android:layout_height="25dp"
+ android:gravity="center"
+ android:orientation="horizontal">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鑱旂郴鐢佃瘽锛�"
+ android:textColor="@color/black"
+ android:textSize="@dimen/common_text_size_little" />
+
+ <TextView
+ android:id="@+id/phone"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:text=""
+ android:textColor="@color/black"
+ android:textSize="@dimen/common_text_size_little" />
+ </LinearLayout>
+
<LinearLayout
android:layout_width="match_parent"
android:layout_height="25dp"
@@ -296,7 +346,6 @@
android:textColor="@color/black"
android:textSize="@dimen/common_text_size_little" />
</LinearLayout>
-
</LinearLayout>
</ScrollView>
diff --git a/expand_button/.gitignore b/expand_button/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/expand_button/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/expand_button/build.gradle b/expand_button/build.gradle
new file mode 100644
index 0000000..8386c9b
--- /dev/null
+++ b/expand_button/build.gradle
@@ -0,0 +1,41 @@
+plugins {
+ id 'com.android.library'
+ id 'org.jetbrains.kotlin.android'
+}
+
+android {
+ namespace 'com.example.expand_button'
+ compileSdk 34
+
+ defaultConfig {
+ minSdk 24
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
+}
+
+dependencies {
+
+ implementation 'androidx.core:core-ktx:1.13.1'
+ implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')
+ implementation 'androidx.appcompat:appcompat:1.7.0'
+ implementation 'com.google.android.material:material:1.12.0'
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.2.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
+}
\ No newline at end of file
diff --git a/expand_button/consumer-rules.pro b/expand_button/consumer-rules.pro
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/expand_button/consumer-rules.pro
diff --git a/expand_button/proguard-rules.pro b/expand_button/proguard-rules.pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/expand_button/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/expand_button/src/androidTest/java/com/example/expand_button/ExampleInstrumentedTest.kt b/expand_button/src/androidTest/java/com/example/expand_button/ExampleInstrumentedTest.kt
new file mode 100644
index 0000000..54ebcbb
--- /dev/null
+++ b/expand_button/src/androidTest/java/com/example/expand_button/ExampleInstrumentedTest.kt
@@ -0,0 +1,24 @@
+package com.example.expand_button
+
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.ext.junit.runners.AndroidJUnit4
+
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import org.junit.Assert.*
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+@RunWith(AndroidJUnit4::class)
+class ExampleInstrumentedTest {
+ @Test
+ fun useAppContext() {
+ // Context of the app under test.
+ val appContext = InstrumentationRegistry.getInstrumentation().targetContext
+ assertEquals("com.example.expand_button.test", appContext.packageName)
+ }
+}
\ No newline at end of file
diff --git a/expand_button/src/main/AndroidManifest.xml b/expand_button/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..a5918e6
--- /dev/null
+++ b/expand_button/src/main/AndroidManifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
+
+</manifest>
\ No newline at end of file
diff --git a/expand_button/src/main/java/com/example/expand_button/ExpandButton.kt b/expand_button/src/main/java/com/example/expand_button/ExpandButton.kt
new file mode 100644
index 0000000..841ce47
--- /dev/null
+++ b/expand_button/src/main/java/com/example/expand_button/ExpandButton.kt
@@ -0,0 +1,14 @@
+package com.example.expand_button
+
+class ExpandButton {
+
+
+
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/expand_button/src/test/java/com/example/expand_button/ExampleUnitTest.kt b/expand_button/src/test/java/com/example/expand_button/ExampleUnitTest.kt
new file mode 100644
index 0000000..a572cdc
--- /dev/null
+++ b/expand_button/src/test/java/com/example/expand_button/ExampleUnitTest.kt
@@ -0,0 +1,17 @@
+package com.example.expand_button
+
+import org.junit.Test
+
+import org.junit.Assert.*
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+class ExampleUnitTest {
+ @Test
+ fun addition_isCorrect() {
+ assertEquals(4, 2 + 2)
+ }
+}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 2739383..82a9a97 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,2 +1,4 @@
rootProject.name = "pipIrrApp"
include ':app'
+include ':mylibrary'
+include ':expand_button'
--
Gitblit v1.8.0