From 755baaf11dd4e5c8eb7a5c2aa0ea23732fe47c85 Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期二, 18 五月 2021 15:16:53 +0800
Subject: [PATCH] 弹窗信息补全
---
src/components/helpers/MapManager.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/src/components/helpers/MapManager.js b/src/components/helpers/MapManager.js
index 625a78e..8399486 100644
--- a/src/components/helpers/MapManager.js
+++ b/src/components/helpers/MapManager.js
@@ -1,22 +1,64 @@
+import AjaxUtils from '../../utils/AjaxUtils'
+import { WMS_URL } from '../../conf/Constants'
+import { highlight, openPropsPopup } from './LocateHelper'
+
class MapManager {
constructor () {
this.hightlightLayer = window.L.featureGroup({}).addTo(window.map)
this.clickDialogSwitch = true // 鍥惧眰鐐瑰嚮寮圭獥寮�鍏�
this.L = window.L
this.map = window.map
+ // wms getfeatureinfo 榛樿鍙傛暟
+ this.defaultWmsParams = {
+ VERSION: '1.1.1',
+ SERVICE: 'WMS',
+ REQUEST: 'GetFeatureInfo',
+ // bbox: bbox,
+ FORMAT: 'image/png',
+ INFO_FORMAT: 'application/json',
+ TRANSPARENT: true,
+ FEATURE_COUNT: 50,
+ SRS: 'EPSG:4326',
+ EXCEPTIONS: 'application/vnd.ogc.se_inimage'
+ }
}
mapClickListener () {
- window.map.on('click', (e) => {
+ this.map.on('click', (e) => {
+ // console.log(e)
+ this.clearHighlight()
+ this.loadWfsDatas(e.latlng).then((res) => {
+ console.log(res)
+ highlight(res.features)
+ openPropsPopup(e.latlng, res.features)
+ })
+ })
+ }
+ loadWfsDatas (latlng, params) {
+ return new Promise((resolve, reject) => {
+ const size = this.map.getSize()
+ var point = this.map.latLngToContainerPoint(latlng, this.map.getZoom())
+ const wmsLayerService = window.layerFactory.wmsLayerService
+ const layers = wmsLayerService.wmsLayerList.getLayers()
+ // const filters = wmsLayerService.wmsLayerList.getFilters()
+ const wmsParams = Object.assign({
+ LAYERS: layers,
+ QUERY_LAYERS: layers,
+ WIDTH: size.x,
+ HEIGHT: size.y,
+ X: Math.round(point.x),
+ Y: Math.round(point.y),
+ BBOX: this.map.getBounds().toBBoxString()
+ }, this.defaultWmsParams, params)
+ AjaxUtils.get4JsonDataByUrl(WMS_URL, wmsParams, (res) => {
+ resolve(res.data)
+ })
})
}
clearHighlight () {
this.hightlightLayer.clearLayers()
- }
-
- iconPoint (latlng) {
}
}
--
Gitblit v1.8.0