Browse Source

添加 olMapGeoDataHost 参数

dev
巴林闲侠 2 years ago
parent
commit
0d7b97863f
  1. 2
      web/client/src/layout/actions/global.js
  2. 4
      web/client/src/layout/reducers/global.js
  3. 161
      web/client/src/sections/quanju/containers/public/olMap.js
  4. 7
      web/config.js
  5. 4
      web/routes/attachment/index.js

2
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,
}
})
});

4
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;

161
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 (
<div id="olMap" style={{ position: 'absolute', height: '100%', width: "100%" }}>
@ -109,8 +110,8 @@ const OlMap = (props) => {
{
olMapOpenData.map(s => {
return <div style={{ display: 'flex' }}>
<div style={{ width: 120 }}>1</div>
<div style={{ flex: 1 }}>: {s.k}</div>
{/* <div style={{ width: 120 }}>1</div>
<div style={{ flex: 1 }}>: {s.k}</div> */}
</div>
})
}
@ -125,6 +126,8 @@ function mapStateToProps (state) {
return {
user: auth.user,
actions: global.actions,
olMapArcgisHost: global.olMapArcgisHost,
olMapGeoDataHost: global.olMapGeoDataHost,
};
}

7
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,// 静态信息

4
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)
}

Loading…
Cancel
Save