diff --git a/web/client/src/sections/quanju/containers/public/olMap.js b/web/client/src/sections/quanju/containers/public/olMap.js index 6f5cc9af..a3da1c71 100644 --- a/web/client/src/sections/quanju/containers/public/olMap.js +++ b/web/client/src/sections/quanju/containers/public/olMap.js @@ -7,6 +7,7 @@ import { OlMapRequest } from '$utils' const OlMap = (props) => { const { dispatch, actions, user, olMapArcgisHost, olMapGeoDataHost, patrolList, roadProjectList, tab, busRunTime, busLine } = props + console.log(patrolList) const [olMapOpenData, setOlMapOpenData] = useState([]) const [olMap, setOlMap] = useState() const [pointItem, setPointItem] = useState({}) @@ -66,10 +67,11 @@ const OlMap = (props) => { olMapTool.closeOverlay('pointClickOpen') olMapTool.removeGeometryLayer('geometry0') + // 请求路线坐标 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}` + params: `{"layerName":"view_by_line","pageSize":1,"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) { @@ -98,6 +100,7 @@ const OlMap = (props) => { positioning: 'top-right' } // 注意 现在只取第一条数据 所以能在这里请求 + // 这里请求的是路线的信息 request.post(`${olMapGeoDataHost || 'http://36.2.6.32:8811'}/geoserver-pg/rest/search`) .type('form') .send({ @@ -184,6 +187,49 @@ const OlMap = (props) => { autoPanMargin: 100, positioning: 'top-right' }) + // 请求路线坐标 + console.log(d.code_road); + if (d.code_road) { + let codeMap = { + x: 'gpsxd', + y: 'gpsyd', + c: 'gpscd', + } + let roadCodeStart = d.code_road[0] + let layerName = codeMap[roadCodeStart.toLowerCase()] + if (layerName) { + request.post(`${olMapGeoDataHost || 'http://36.2.6.32:8811'}/geoserver-pg/rest/search`) + .type('form') + .send({ + params: `{"layerName":"${layerName}","filter":"(roadcode = '${d.code_road}')","spatialFilter":"","isReturnGeometry":"true","orderByFields":"roadcode, roadstart asc","spatialRel":"INTERSECTS","pageNum":1,"pageSize":99}` + }) + .then(res => { + if (res.status == 200 && res.body && res.body.code == 1) { + console.log(res); + const data = res.body.data + const { datalist } = data + if (datalist?.list?.length) { + let index = 0 + for (let d of datalist.list) { + olMap.addGeometryJMLayer({ + features: [ + { + geometry: d.shape, + geometryType: 'LineString', + // geometryType: 'Point', + }, + ], + style: { stroke: { width: 5, color: '#9933FF' } }, + selectStyle: { stroke: { width: 8, color: '#9933FF' } }, + layerName: 'geometry' + index++ + }); + } + } + } + }) + } + } + } }, geometry: [d.longitude, d.latitude], @@ -217,6 +263,10 @@ const OlMap = (props) => { layerName: 'geometry_patrol_' + index }); }); + } else if (tab != 'conserve' && olMap) { + patrolList.forEach((d, index) => { + olMap.removeGeometryLayer('geometry_patrol_' + index) + }) } }, [patrolList, olMap, tab]) @@ -250,6 +300,8 @@ const OlMap = (props) => { autoPanMargin: 100, positioning: 'top-right' }) + // 查路线 + } }, geometry: [d.longitude, d.latitude],