From 241d327e57cbfe504aa806c61aa22e6205706098 Mon Sep 17 00:00:00 2001
From: sgj <1442489573@qq.com>
Date: 星期六, 11 四月 2026 16:59:46 +0800
Subject: [PATCH] 引用纠正
---
fzzy-igdss-web/src/main/resources/static/security/patrol-record.js | 126 +++++++++++++++--------------------------
1 files changed, 47 insertions(+), 79 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;
--
Gitblit v1.9.3