From 8e182aa12fcba7ed25c2d65a6f5e1ae0b2160ab1 Mon Sep 17 00:00:00 2001 From: 徐旺旺 <11530253@qq.com> Date: 星期四, 20 五月 2021 15:09:54 +0800 Subject: [PATCH] 装置区问题修复 --- src/components/helpers/LocateHelper.js | 76 ++++++++++++++++++++++++------------- 1 files changed, 49 insertions(+), 27 deletions(-) diff --git a/src/components/helpers/LocateHelper.js b/src/components/helpers/LocateHelper.js index edfc65c..9e346c1 100644 --- a/src/components/helpers/LocateHelper.js +++ b/src/components/helpers/LocateHelper.js @@ -10,21 +10,31 @@ 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 ') + } + console.log(centerPoint) + 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) } @@ -38,7 +48,7 @@ if (type === 'Point') { var point = feature.geometry.coordinates point = [point[1], point[0]] - window.map.setView(point, 17) + window.map.setView(point, 19) } else { window.map.fitBounds(window.L.geoJSON(feature).getBounds()) } @@ -58,16 +68,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, { @@ -76,6 +77,25 @@ color: 'red' } } + }).addTo(highlightLayer) + } +} + +/** + * 楂樹寒鐐逛綅鍥炬爣 + * @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) } } @@ -111,8 +131,10 @@ if (type === 'Point') { return [coordinates[1], coordinates[0]] } else { - const center = L.geoJSON(feature, {}).getBounds().getCenter() - return [center.lat, center.lng] + return L.geoJSON(feature, {}).getBounds().getSouthWest() + // return [center.lat, center.lng] + + // return turf.centerOfMass(L.geoJSON(feature, {}).toGeoJSON()) } } -- Gitblit v1.8.0