From 81e426e19db140e630f45409c1569fe16dbcc33f Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期二, 18 五月 2021 15:25:19 +0800
Subject: [PATCH] 修复点击弹窗bug
---
src/components/helpers/LocateHelper.js | 64 +++++++++++++++++--------------
1 files changed, 35 insertions(+), 29 deletions(-)
diff --git a/src/components/helpers/LocateHelper.js b/src/components/helpers/LocateHelper.js
index 2454138..6354244 100644
--- a/src/components/helpers/LocateHelper.js
+++ b/src/components/helpers/LocateHelper.js
@@ -51,36 +51,42 @@
}
export const highlight = function (feature, icon) {
- const L = window.L
- const type = feature.geometry.type
- window.mapManager.clearHighlight()
- const highlightLayer = window.mapManager.hightlightLayer
- if (type === 'MultiLineString') {
- L.geoJSON(feature, {
- style: function () {
- return {
- fillColor: 'red',
- color: 'red'
- }
- }
- }).addTo(highlightLayer)
- } else if (type === 'Point') {
- // 鍙犲姞涓�涓ぇ灏哄鐨勫浘鏍�
- let point = feature.geometry.coordinates
- point = [point[1], point[0]]
-
- if (icon) {
- L.marker(point, {
- icon: L.icon({
- iconUrl: '/assets/images/map/' + icon,
- iconSize: [30, 30],
- iconAnchor: [15, 15]
- })
- }).addTo(highlightLayer)
+ if (Array.isArray(feature)) {
+ for (let i = 0; i < feature.length; i++) {
+ highlight(feature[i], icon)
}
- pulseEffect(point)
- } else if (type === 'LineString') {
- L.polyline(reversePolyLine(feature), { color: 'red' }).addTo(highlightLayer)
+ } else {
+ const L = window.L
+ const type = feature.geometry.type
+ window.mapManager.clearHighlight()
+ const highlightLayer = window.mapManager.hightlightLayer
+ if (type === 'MultiLineString') {
+ L.geoJSON(feature, {
+ style: function () {
+ return {
+ fillColor: 'red',
+ color: 'red'
+ }
+ }
+ }).addTo(highlightLayer)
+ } else if (type === 'Point') {
+ // 鍙犲姞涓�涓ぇ灏哄鐨勫浘鏍�
+ let point = feature.geometry.coordinates
+ point = [point[1], point[0]]
+
+ if (icon) {
+ L.marker(point, {
+ icon: L.icon({
+ iconUrl: '/assets/images/map/' + icon,
+ iconSize: [30, 30],
+ iconAnchor: [15, 15]
+ })
+ }).addTo(highlightLayer)
+ }
+ pulseEffect(point)
+ } else if (type === 'LineString') {
+ L.polyline(reversePolyLine(feature), { color: 'red' }).addTo(highlightLayer)
+ }
}
}
--
Gitblit v1.8.0