From 52ccae38d7d236765eb2dfd8c325fd94f99d43b1 Mon Sep 17 00:00:00 2001
From: YYC <1833023622@qq.com>
Date: 星期一, 02 三月 2026 14:38:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
fzzy-igdss-web/src/main/resources/templates/security/patrol-record.html | 18 ++++--
fzzy-igdss-web/src/main/resources/static/security/patrol-record.js | 126 +++++++++++++++--------------------------
2 files changed, 59 insertions(+), 85 deletions(-)
diff --git a/fzzy-igdss-web/src/main/resources/static/security/patrol-record.js b/fzzy-igdss-web/src/main/resources/static/security/patrol-record.js
index 8a0e4be..9a0f1b0 100644
--- a/fzzy-igdss-web/src/main/resources/static/security/patrol-record.js
+++ b/fzzy-igdss-web/src/main/resources/static/security/patrol-record.js
@@ -5,10 +5,10 @@
layer = layui.layer;
});
});
+
function initMap() {
- // 鍙垹闄や唬鐮佸紑濮�
- // 妫�鏌ョ櫨搴﹀湴鍥続PI鏄惁鍔犺浇鎴愬姛
- if (typeof BMapGL === 'undefined') {
+ // 妫�鏌ラ珮寰峰湴鍥続PI鏄惁鍔犺浇鎴愬姛
+ if (typeof AMap === 'undefined') {
layer.msg("鍦板浘鍔犺浇澶辫触锛岃妫�鏌ョ綉缁滆繛鎺ワ紒", {icon: 2});
return;
}
@@ -23,54 +23,60 @@
// 妫�鏌ユ暟鎹�
if (!patrolRecordList || patrolRecordList.length === 0) {
layer.msg("鏆傛棤杞ㄨ抗鏁版嵁锛�", {icon: 2});
- var defaultPoint = new BMapGL.Point(116.404, 39.915);
- map.centerAndZoom(defaultPoint, 12);
- map.enableScrollWheelZoom(true);
+ var defaultPoint = [116.404, 39.915]; // 楂樺痉鍦板浘浣跨敤鏁扮粍鏍煎紡[缁忓害,绾害]
+ map = new AMap.Map("map", {
+ zoom: 12,
+ center: defaultPoint
+ });
return;
}
- //鍙垹闄や唬鐮佺粨鏉�
- // ========== 鐧惧害鍦板浘鍒濆鍖栦笌杞ㄨ抗娓叉煋 ==========
+ // ========== 楂樺痉鍦板浘鍒濆鍖栦笌杞ㄨ抗娓叉煋 ==========
// 1. 鍒濆鍖栧湴鍥�
- var map = new BMapGL.Map("map");
+ var map = new AMap.Map("map", {
+ zoom: 13,
+ center: [116.404, 39.915] // 榛樿涓績鐐�
+ });
+
// 2. 鑾峰彇杞ㄨ抗鐐规暟鎹�
if (patrolRecordList.length === 0) {
layer.msg("鏆傛棤杞ㄨ抗鏁版嵁锛�", {icon: 2});
- var defaultPoint = new BMapGL.Point(116.404, 39.915);
- map.centerAndZoom(defaultPoint, 14);
- map.enableScrollWheelZoom(true);
+ map.setZoom(14);
return;
}
-
// 3. 鏋勯�犺建杩圭偣鏁扮粍鍜屾爣璁扮偣鏁扮粍
- var points = []; // 杞ㄨ抗鎶樼嚎鐐�
+ var points = []; // 杞ㄨ抗鍧愭爣鐐�
var markers = []; // 鍦板浘鏍囪鐐�
var cardElements = document.querySelectorAll('.track-card'); // 鎵�鏈夊崱鐗囧厓绱�
-
-
patrolRecordList.forEach(function (record, index) {
var lng = record.longitude;
var lat = record.latitude;
- var point = new BMapGL.Point(lng, lat);
+ var point = [lng, lat]; // 楂樺痉鍦板浘浣跨敤鏁扮粍鏍煎紡[缁忓害,绾害]
points.push(point);
// 鍒涘缓鍦板浘鏍囪鐐�
- var marker = new BMapGL.Marker(point);
+ var marker = new AMap.Marker({
+ position: point,
+ map: map
+ });
markers.push(marker);
// 鏍囪鐐瑰脊绐椾俊鎭�
- var infoWindow = new BMapGL.InfoWindow(`
- <div style="font-size: 12px; line-height: 1.8;">
+ var infoWindow = new AMap.InfoWindow({
+ content: `
+ <div style="font-size: 12px; line-height: 1.8; padding: 10px;">
<p><strong>宸℃浜猴細</strong>${record.createBy}</p>
<p><strong>宸℃鏃堕棿锛�</strong>${new Date(record.createTime).toLocaleString()}</p>
<p><strong>缁忕含搴︼細</strong>${lat}, ${lng}</p>
</div>
- `);
+ `,
+ offset: new AMap.Pixel(0, -30)
+ });
// 鏍囪鐐圭偣鍑讳簨浠讹細楂樹寒瀵瑰簲鍗$墖 + 鏄剧ず寮圭獥
- marker.addEventListener("click", function () {
+ marker.on('click', function () {
// 绉婚櫎鎵�鏈夊崱鐗囩殑active鏍峰紡
cardElements.forEach(el => el.classList.remove('active'));
// 楂樹寒褰撳墠鍗$墖
@@ -78,7 +84,7 @@
// 婊氬姩鍒板綋鍓嶅崱鐗�
cardElements[index].scrollIntoView({behavior: 'smooth', block: 'center'});
// 鏄剧ず寮圭獥
- this.openInfoWindow(infoWindow);
+ infoWindow.open(map, point);
});
// 鍗$墖鐐瑰嚮浜嬩欢锛氬畾浣嶅埌瀵瑰簲鏍囪鐐� + 楂樹寒鍗$墖
@@ -88,74 +94,36 @@
// 楂樹寒褰撳墠鍗$墖
this.classList.add('active');
// 鍦板浘涓績瀹氫綅鍒板綋鍓嶆爣璁扮偣
- map.centerAndZoom(point, 15);
+ map.setCenter(point);
+ map.setZoom(15);
// 鏄剧ず鏍囪鐐瑰脊绐�
- marker.openInfoWindow(infoWindow);
- // 杞诲井鍔ㄧ敾鏁堟灉
- marker.setAnimation(BMAP_ANIMATION_BOUNCE);
- setTimeout(() => marker.setAnimation(null), 1500);
+ infoWindow.open(map, point);
+ // 杞诲井鍔ㄧ敾鏁堟灉锛堥珮寰峰湴鍥炬病鏈夌洿鎺ョ殑bounce鍔ㄧ敾锛屽彲浠ヤ娇鐢ㄨ烦鍔ㄦ晥鏋滐級
+ marker.setAnimation('AMAP_ANIMATION_DROP');
});
-
- map.addOverlay(marker);
});
- // 瀵绘壘points涓棿鐨勭偣浣�
+ // 瀵绘壘points涓棿鐨勭偣浣嶄綔涓轰腑蹇冪偣
var midIndex = Math.floor(points.length / 2);
- const centerPoint = points[midIndex] || new BMapGL.Point(116.404, 39.915);
- map.centerAndZoom(centerPoint, 13); // 14涓哄湴鍥剧缉鏀剧骇鍒�
+ var centerPoint = points[midIndex] || [116.404, 39.915];
+ map.setCenter(centerPoint);
// 4. 缁樺埗杞ㄨ抗鎶樼嚎
- var polyline = new BMapGL.Polyline(points, {
+ var polyline = new AMap.Polyline({
+ path: points,
strokeColor: "#1890ff", // 涓昏壊璋冿細钃濊壊
strokeWeight: 6, // 鎶樼嚎瀹藉害
strokeOpacity: 0.8, // 閫忔槑搴�
- strokeStyle: 'solid' // 瀹炵嚎
+ isOutline: true,
+ outlineColor: '#ffffff',
+ borderWeight: 1
});
- map.addOverlay(polyline);
+ map.add(polyline);
- // // 5. 璧风偣/缁堢偣鐗规畩鏍囪
- // // 璧风偣鏍囪
- // var startMarker = new BMapGL.Marker(points[0], {
- // icon: new BMapGL.Icon("http://api.map.baidu.com/img/markers.png", new BMapGL.Size(25, 34), {
- // offset: new BMapGL.Size(12, 34),
- // imageOffset: new BMapGL.Size(0, 0) // 璧风偣鍥炬爣
- // })
- // });
- // map.addOverlay(startMarker);
- // // startMarker.setLabel(new BMapGL.Label("璧风偣锛�" + patrolRecordList[0].pointName, {
- // // offset: new BMapGL.Size(30, -15),
- // // styles: {fontSize: '12px', color: '#fff', background: '#52c41a', padding: '0px 14px', borderRadius: '3px'}
- // // }));
- // startMarker.setLabel(new BMapGL.Label("璧风偣锛�" + patrolRecordList[0].pointName, {
- // offset: new BMapGL.Size(30, -15),
- // styles: {
- // fontSize: '12px',
- // color: '#fff',
- // background: '#52c41a',
- // padding: '8px 8px', // 宸﹀彸padding淇濇寔涓�鑷达紙14px锛夛紝淇濊瘉鑳屾櫙涓や晶绌洪棿瀵圭О
- // borderRadius: '3px',
- // textAlign: 'center' // 鏂板锛氬己鍒舵枃瀛楀湪鑳屾櫙鍐呮按骞冲眳涓�
- // }
- // }));
- //
- // // 缁堢偣鏍囪
- // var endMarker = new BMapGL.Marker(points[points.length - 1], {
- // icon: new BMapGL.Icon("http://api.map.baidu.com/img/markers.png", new BMapGL.Size(25, 34), {
- // offset: new BMapGL.Size(12, 34),
- // imageOffset: new BMapGL.Size(-114, 0) // 缁堢偣鍥炬爣
- // })
- // });
- // map.addOverlay(endMarker);
- // endMarker.setLabel(new BMapGL.Label("缁堢偣锛�" + patrolRecordList[patrolRecordList.length - 1].pointName, {
- // offset: new BMapGL.Size(30, -15),
- // styles: {fontSize: '12px', color: '#fff', background: '#ff4d4f', padding: '0px 14px', borderRadius: '3px'}
- // }));
+ // 5. 鍦板浘鑷�傚簲鎵�鏈夎建杩圭偣
+ map.setFitView();
- // 6. 鍦板浘鑷�傚簲鎵�鏈夎建杩圭偣
- map.enableScrollWheelZoom(true); // 寮�鍚粴杞缉鏀�
- map.setViewport(points); // 閫傞厤鎵�鏈夎建杩圭偣
-
- // 7. 鍒濆鎻愮ず
+ // 6. 鍒濆鎻愮ず
layer.msg("杞ㄨ抗鍔犺浇瀹屾垚锛佺偣鍑诲崱鐗囧彲瀹氫綅鍒板搴旂偣浣�", {
icon: 1,
time: 3000,
@@ -164,4 +132,4 @@
}
// 椤甸潰鍔犺浇瀹屾垚鍚庡垵濮嬪寲鍦板浘
-window.onload = initMap;
\ No newline at end of file
+window.onload = initMap;
diff --git a/fzzy-igdss-web/src/main/resources/templates/security/patrol-record.html b/fzzy-igdss-web/src/main/resources/templates/security/patrol-record.html
index 5c14626..5af3551 100644
--- a/fzzy-igdss-web/src/main/resources/templates/security/patrol-record.html
+++ b/fzzy-igdss-web/src/main/resources/templates/security/patrol-record.html
@@ -7,12 +7,18 @@
<th:block th:include="include :: header('宸℃洿璁板綍')"/>
<link rel="stylesheet" type="text/css" th:href="@{/ajax/libs/layui-ruoyi/css/layui.css}"/>
<link rel="stylesheet" th:href="@{/security/patrol-record-style.css}">
- <script type="text/javascript" src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=R3FfyIEbBAWNckTqRSopHQktdkgp924F"></script>
+ <script type="text/javascript">
+ window._AMapSecurityConfig = {
+ securityJsCode: "1f590b908daf435350b6b4b238fa62eb",
+ };
+ </script>
+ <script type="text/javascript"
+ src="https://webapi.amap.com/maps?v=2.0&key=51d35f2501da9369a8132895cca0fc94"></script>
</head>
<body>
<div class="container-div">
<div class="row">
- <!-- 鐧惧害鍦板浘瀹瑰櫒 -->
+ <!-- 楂樺痉鍦板浘瀹瑰櫒 -->
<div id="map"></div>
<!-- 鍙充晶杞ㄨ抗鍗$墖鎮诞灞� -->
<div class="track-card-panel">
@@ -23,7 +29,8 @@
<!-- 杞ㄨ抗鍗$墖鍒楄〃锛圱hymeleaf寰幆娓叉煋锛� -->
<div th:each="record,stat : ${patrolRecordList}" class="track-card" data-index="${stat.index}">
<div style="margin-bottom: 10px">
- <img style="width: 100%;max-height: 200px;" th:src="${record.imgName ?: '/logo-sm.png'}" th:data-id="${record.id}">
+ <img style="width: 100%;max-height: 200px;" th:src="${record.imgName ?: '/logo-sm.png'}"
+ th:data-id="${record.id}">
</div>
<div class="card-row">
<span class="label">宸� 妫� 浜猴細</span>
@@ -39,13 +46,12 @@
</div>
-
<!-- 寮曞叆Layui JS -->
<th:block th:include="include :: footer"/>
<script th:src="@{/ajax/libs/layui-ruoyi/layui.js}"></script>
<script th:src="@{/security/patrol-record.js}"></script>
-<script th:inline="javascript">
+<script th:inline="javascript">
var patrolRecordList = [[${patrolRecordList}]];
</script>
</body>
-</html>
\ No newline at end of file
+</html>
--
Gitblit v1.9.3