From f7b244103e748e051537cf4b46e875acaf56c450 Mon Sep 17 00:00:00 2001 From: 徐旺旺 <11530253@qq.com> Date: 星期三, 19 五月 2021 16:03:22 +0800 Subject: [PATCH] 重封装定位js --- src/components/helpers/LocateHelper.js | 67 +++++++++++++++++++++------------ 1 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/components/helpers/LocateHelper.js b/src/components/helpers/LocateHelper.js index edfc65c..0951b45 100644 --- a/src/components/helpers/LocateHelper.js +++ b/src/components/helpers/LocateHelper.js @@ -10,21 +10,30 @@ export const locate = function (feature, config, filter) { fitBounds(feature) highlight(feature, config.icon) + const centerPoint = getCenterPoint(feature) + const params = { LAYERS: config.layerGroup || config.typeName, QUERY_LAYERS: config.layerGroup || config.typeName } + const filters = [] + if (config.filter) { + filters[filters.length] = config.filter + } + if (filter) { + filters[filters.length] = filter + } + if (filters.length > 0) { + params.CQL_FILTER = filters.join(' AND ') + } + loadPointWfs(centerPoint, params) +} + +/** + * 鍔犺浇鐐硅寖鍥寸殑wfs鏁版嵁骞跺脊绐� + * @param latlng 鐐圭殑缁忕含搴﹀潗鏍� + * @param params + */ +export const loadPointWfs = function (latlng, params) { setTimeout(() => { - const centerPoint = getCenterPoint(feature) - const params = { LAYERS: config.layerGroup || config.typeName, QUERY_LAYERS: config.layerGroup || config.typeName } - const filters = [] - if (config.filter) { - filters[filters.length] = config.filter - } - if (filter) { - filters[filters.length] = filter - } - if (filters.length > 0) { - params.CQL_FILTER = filters.join(' AND ') - } - window.mapManager.loadWfsDatas(centerPoint, params).then((res) => { - openPropsPopup(centerPoint, res.features) + window.mapManager.loadWfsDatas(latlng, params).then((res) => { + openPropsPopup(latlng, res.features) }) }, 1000) } @@ -58,16 +67,7 @@ // 鍙犲姞涓�涓ぇ灏哄鐨勫浘鏍� 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) - } + pointZoom(point, icon) pulseEffect(point) } else { L.geoJSON(feature, { @@ -81,6 +81,25 @@ } /** + * 楂樹寒鐐逛綅鍥炬爣 + * @param latlng 缁忕含搴� + * @param icon 鍥炬爣 + */ +export const pointZoom = function (latlng, icon) { + const L = window.L + const highlightLayer = window.mapManager.hightlightLayer + if (icon) { + L.marker(latlng, { + icon: L.icon({ + iconUrl: '/assets/images/map/' + icon, + iconSize: [30, 30], + iconAnchor: [15, 15] + }) + }).addTo(highlightLayer) + } +} + +/** * 寮瑰嚭灞炴�у垪琛ㄥ睍绀虹獥鍙� * @param xy 寮瑰嚭绐楀彛璺熼殢瑕佺礌鐨勭粡绾害 * @param layer 鏌ヨ鎸囧畾鐨勫浘灞傘�備笉鎸囧畾鏃讹紝榛樿涓哄嬀閫夌殑鍥惧眰 -- Gitblit v1.8.0