From 0d7b97863f203e9bf793fea9a9d5219472d48fd3 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Thu, 13 Jul 2023 14:20:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20olMapGeoDataHost=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/client/src/layout/actions/global.js | 2 + web/client/src/layout/reducers/global.js | 4 + .../quanju/containers/public/olMap.js | 161 +++++++++--------- web/config.js | 7 + web/routes/attachment/index.js | 4 +- 5 files changed, 97 insertions(+), 81 deletions(-) diff --git a/web/client/src/layout/actions/global.js b/web/client/src/layout/actions/global.js index 4b08442c..55232c48 100644 --- a/web/client/src/layout/actions/global.js +++ b/web/client/src/layout/actions/global.js @@ -38,6 +38,8 @@ export function initApiRoot () { apiRoot: res.root, vcmpWebUrl: res.vcmpWebUrl, vcmpMirrorId: res.vcmpMirrorId, + olMapArcgisHost: res.olMapArcgisHost, + olMapGeoDataHost: res.olMapGeoDataHost, } }) }); diff --git a/web/client/src/layout/reducers/global.js b/web/client/src/layout/reducers/global.js index 4edb421f..a4d2cf4b 100644 --- a/web/client/src/layout/reducers/global.js +++ b/web/client/src/layout/reducers/global.js @@ -13,6 +13,8 @@ function global (state = { apiRoot: '', vcmpWebUrl: '', vcmpMirrorId: '', + olMapArcgisHost: '', + olMapGeoDataHost: '' }, action) { const payload = action.payload; switch (action.type) { @@ -42,6 +44,8 @@ function global (state = { apiRoot: payload.apiRoot, vcmpWebUrl: payload.vcmpWebUrl, vcmpMirrorId: payload.vcmpMirrorId, + olMapArcgisHost: payload.olMapArcgisHost, + olMapGeoDataHost: payload.olMapGeoDataHost, }).toJS(); default: return state; diff --git a/web/client/src/sections/quanju/containers/public/olMap.js b/web/client/src/sections/quanju/containers/public/olMap.js index 5be87729..b6b9e6ec 100644 --- a/web/client/src/sections/quanju/containers/public/olMap.js +++ b/web/client/src/sections/quanju/containers/public/olMap.js @@ -4,93 +4,94 @@ import request from 'superagent' import { OlMapRequest } from '$utils' const OlMap = (props) => { - const { dispatch, actions, user } = props + const { dispatch, actions, user, olMapArcgisHost, olMapGeoDataHost } = props const [olMapOpenData, setOlMapOpenData] = useState([]) useEffect(() => { - let config = { - layerName: 'nanchang', - center: [116.08706, 28.602018], // 中心坐标 - zoom: 10, // 缩放 - minZoom: 8, - maxZoom: 21, - isMoveSelect: false, // 鼠标滑过是否选中 - projection: 'EPSG:4326' // 坐标系 - } - let arcgisUrls = { - nanchang: { - url: 'http://36.2.6.33:6080/arcgis/rest/services/PBDT/nachang/MapServer', - }, - } - + }, []) + useEffect(() => { + console.log(olMapGeoDataHost); + if (olMapGeoDataHost) { + let config = { + layerName: 'nanchang', + center: [116.08706, 28.602018], // 中心坐标 + zoom: 10, // 缩放 + minZoom: 8, + maxZoom: 21, + isMoveSelect: false, // 鼠标滑过是否选中 + projection: 'EPSG:4326' // 坐标系 + } + let arcgisUrls = { + nanchang: { + url: `${olMapArcgisHost || 'http://36.2.6.33:6080'}/arcgis/rest/services/PBDT/nachang/MapServer`, + }, + } - let option = { - target: 'olMap', // 元素ID - config: config, - arcgisUrls, // 动态底图图层 - onEvent: { - // 选中回调 - onSelectClick: function (p) { console.log(p) }, - // 鼠标滑过回调 - onPointerMove: function (p) { console.log(p) }, + let option = { + target: 'olMap', // 元素ID + config: config, + arcgisUrls, // 动态底图图层 + onEvent: { + // 选中回调 + onSelectClick: function (p) { + // console.log(p) + }, + // 鼠标滑过回调 + onPointerMove: function (p) { + // console.log(p) + }, + } } - } - let olMapTool = new OlMapTool(option) - olMapTool.map.on('dblclick', function (p) { - console.log(p) - }) - olMapTool.map.on('singleclick', function (p) { - console.log("singleclick", p) + let olMapTool = new OlMapTool(option) + olMapTool.map.on('dblclick', function (p) { + // console.log(p) + }) + olMapTool.map.on('singleclick', function (p) { - olMapTool.closeOverlay('clickOpen') - olMapTool.removeGeometryLayer('geometry0') + olMapTool.closeOverlay('clickOpen') + olMapTool.removeGeometryLayer('geometry0') - request.post('http://36.2.6.32:8811/geoserver-pg/rest/bufferSearch') - .type('form') - .send({ - params: `{"layerName":"view_by_line","pageSize":10,"pageNum":1,"filter":"","isReturnGeometry":"true","spatialRel":"INTERSECTS","orderByFields":" sort1, sort2, lxbm, sxxfx, qdzh asc", "spatialFilter":"point(${p.coordinate[0]} ${p.coordinate[1]})","distance":20}` - }) - .then(res => { - console.log(res); - if (res.status == 200 && res.body && res.body.code == 1) { - const data = res.body.data - const { datalist } = data - let index = 0 - for (let d of datalist.list) { - olMapTool.addGeometryJMLayer({ - features: [ - { - geometry: d.shape, - geometryType: 'LineString', - // geometryType: 'Point', - }, - ], - style: { stroke: { width: 10, color: '#9933FF' } }, - selectStyle: { stroke: { width: 5, color: '#9933FF' } }, - layerName: 'geometry' + index++ - }); - const config = { - id: 'clickOpen', - offset: [0, 25], // 偏移 - position: p.coordinate, // 坐标 - autoPan: true, - autoPanMargin: 100, - positioning: 'top-right' + request.post(`${olMapGeoDataHost || 'http://36.2.6.32:8811'}/geoserver-pg/rest/bufferSearch`) + .type('form') + .send({ + params: `{"layerName":"view_by_line","pageSize":10,"pageNum":1,"filter":"","isReturnGeometry":"true","spatialRel":"INTERSECTS","orderByFields":" sort1, sort2, lxbm, sxxfx, qdzh asc", "spatialFilter":"point(${p.coordinate[0]} ${p.coordinate[1]})","distance":20}` + }) + .then(res => { + if (res.status == 200 && res.body && res.body.code == 1) { + const data = res.body.data + const { datalist } = data + let index = 0 + for (let d of datalist.list) { + olMapTool.addGeometryJMLayer({ + features: [ + { + geometry: d.shape, + geometryType: 'LineString', + // geometryType: 'Point', + }, + ], + style: { stroke: { width: 10, color: '#9933FF' } }, + selectStyle: { stroke: { width: 5, color: '#9933FF' } }, + layerName: 'geometry' + index++ + }); + const config = { + id: 'clickOpen', + offset: [0, 25], // 偏移 + position: p.coordinate, // 坐标 + autoPan: true, + autoPanMargin: 100, + positioning: 'top-right' + } + setOlMapOpenData([{ k: Math.random() }]) + olMapTool.addOverlay('clickOpen', config) + break } - setOlMapOpenData([{ k: Math.random() }]) - olMapTool.addOverlay('clickOpen', config) - break } - } - }) - - }) - - - - - }, []) + }) + }) + } + }, [olMapGeoDataHost]) return (
@@ -109,8 +110,8 @@ const OlMap = (props) => { { olMapOpenData.map(s => { return
-
1
-
: {s.k}
+ {/*
1
+
: {s.k}
*/}
}) } @@ -125,6 +126,8 @@ function mapStateToProps (state) { return { user: auth.user, actions: global.actions, + olMapArcgisHost: global.olMapArcgisHost, + olMapGeoDataHost: global.olMapGeoDataHost, }; } diff --git a/web/config.js b/web/config.js index 27b84b6b..45a15d95 100644 --- a/web/config.js +++ b/web/config.js @@ -20,6 +20,8 @@ args.option(['r', 'report-node'], '报表进程地址'); args.option('qndmn', '七牛'); args.option('vcmpWebUrl', '视频平台web可访问地址'); args.option('vcmpMirrorId', '视频平台镜像服务id') +args.option('olMapArcgisHost', '江西公路地图 arcgis 查询地址') +args.option('olMapGeoDataHost', '江西公路地图 geoData 查询地址') const flags = args.parse(process.argv); @@ -29,6 +31,9 @@ const API_URL = process.env.API_URL || flags.apiUrl; // const VCMP_WEB_URL = process.env.VCMP_WEB_URL || flags.vcmpWebUrl; const VCMP_MIRROR_ID = process.env.VCMP_MIRROR_ID || flags.vcmpMirrorId; +// +const OL_MAP_ARC_GIS_HOST = process.env.OL_MAP_ARC_GIS_HOST || flags.olMapArcgisHost || 'http://36.2.6.33:6080'; +const OL_MAP_GEO_DATA_HOST = process.env.OL_MAP_GEO_DATA_HOST || flags.olMapGeoDataHost || 'http://36.2.6.32:8811'; if ( !FS_UNIAPP_API || @@ -68,6 +73,8 @@ const product = { vcmpWebUrl: VCMP_WEB_URL, vcmpMirrorId: VCMP_MIRROR_ID, staticRoot: './client', + olMapArcgisHost: OL_MAP_ARC_GIS_HOST, + olMapGeoDataHost: OL_MAP_GEO_DATA_HOST } }, { entry: require('./client').entry,// 静态信息 diff --git a/web/routes/attachment/index.js b/web/routes/attachment/index.js index e1c2d916..1ea01d32 100644 --- a/web/routes/attachment/index.js +++ b/web/routes/attachment/index.js @@ -19,9 +19,9 @@ module.exports = { entry: function (app, router, opts) { const getApiRoot = async function (ctx) { try { - const { apiUrl, qndmn, vcmpWebUrl, vcmpMirrorId } = opts; + const { apiUrl, qndmn, vcmpWebUrl, vcmpMirrorId, olMapArcgisHost, olMapGeoDataHost } = opts; ctx.status = 200; - ctx.body = { root: apiUrl, qndmn, vcmpWebUrl, vcmpMirrorId }; + ctx.body = { root: apiUrl, qndmn, vcmpWebUrl, vcmpMirrorId, olMapArcgisHost, olMapGeoDataHost }; } catch (error) { console.error('getApiRoot', error) }