From 3b79ee564d4c77189484711ece4dc80786f79080 Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期一, 17 五月 2021 14:34:20 +0800
Subject: [PATCH] 定位、高亮重封装
---
src/utils/utils.js | 62 +++++++++++++++++++++++++++++++
1 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/src/utils/utils.js b/src/utils/utils.js
index ef770cb..53116c0 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -24,6 +24,68 @@
}
/**
+ * 鑴夊啿鏁堟灉
+ */
+export function pulseEffect (xy) {
+ let times = 50
+ const colors = ['#00f100', '#ff0000']
+ // 鎻掍欢 鏁堟灉瀹炵幇
+ var pulsingIcon = window.L.icon.pulse({
+ iconSize: [30, 30],
+ color: colors[0],
+ fillColor: ''
+ })
+ var picGroupMarker = window.L.marker(xy, { icon: pulsingIcon }).addTo(window.map)
+ // 瀹氭椂
+ var timeInterval = setInterval(() => {
+ if (times > 0) {
+ times--
+ } else {
+ clearInterval(timeInterval)
+ picGroupMarker.remove()
+ }
+ }, 1000)
+}
+
+export function reversePolyLine (feature) {
+ const coordinates = feature.geometry.coordinates
+ var latlng = []
+ for (var j = 0; j < coordinates.length; j++) {
+ const coordinate = coordinates[j]
+ latlng.push(coordinate.reverse())
+ }
+ return latlng
+}
+
+export function reverseMultiLine (feature) {
+ const coordinates = feature.geometry.coordinates
+ var latlng = []
+ for (var j = 0; j < coordinates.length; j++) {
+ const coordinate = coordinates[j]
+ var xy = []
+ for (var k = 0; k < coordinate.length; k++) {
+ const coor = coordinate[k]
+ xy.push(coor.reverse())
+ }
+ latlng.push(xy)
+ }
+ return latlng
+}
+
+/**
+ * 璁剧疆寮圭獥骞崇Щ浣嶇疆
+ * @param pos
+ * @param value
+ */
+export function setPanTo (pos, value) {
+ var position = pos
+ position = window.map.latLngToLayerPoint(position)
+ position.y += value
+ position = window.map.layerPointToLatLng(position)
+ window.map.flyTo(position)
+}
+
+/**
* 澶嶅埗瀵硅薄
* @param obj
* @returns {{}}
--
Gitblit v1.8.0