From c83f3a19cffca87e74433bc1c53fe4623c35c2b0 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Wed, 19 Jul 2023 21:25:39 +0800 Subject: [PATCH] =?UTF-8?q?GIS=20=E5=BB=BA=E8=AE=BE=E7=9A=84=E7=82=B9?= =?UTF-8?q?=E9=83=A8=E5=9C=A8=E5=BB=BA=E8=AE=BEtab=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/sections/quanju/containers/example.js | 4 +++- .../quanju/containers/public/olMap.js | 22 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/web/client/src/sections/quanju/containers/example.js b/web/client/src/sections/quanju/containers/example.js index 7d511841..16076718 100644 --- a/web/client/src/sections/quanju/containers/example.js +++ b/web/client/src/sections/quanju/containers/example.js @@ -32,6 +32,8 @@ const Example = (props) => { setPatrolList(res.payload.data || []) } }) + } + if (tab === 'build') { dispatch(getReportList({ reportType: 'road', isTop: true @@ -56,7 +58,7 @@ const Example = (props) => {
{/* */} - +
diff --git a/web/client/src/sections/quanju/containers/public/olMap.js b/web/client/src/sections/quanju/containers/public/olMap.js index 7117cefa..28c0af62 100644 --- a/web/client/src/sections/quanju/containers/public/olMap.js +++ b/web/client/src/sections/quanju/containers/public/olMap.js @@ -6,14 +6,14 @@ import moment from 'moment'; import { OlMapRequest } from '$utils' const OlMap = (props) => { - const { dispatch, actions, user, olMapArcgisHost, olMapGeoDataHost, patrolList, roadProjectList } = props + const { dispatch, actions, user, olMapArcgisHost, olMapGeoDataHost, patrolList, roadProjectList, tab } = props const [olMapOpenData, setOlMapOpenData] = useState([]) const [olMap, setOlMap] = useState() const [pointItem, setPointItem] = useState({}) useEffect(() => { - }, []) + }, [tab]) useEffect(() => { if (olMapGeoDataHost) { @@ -148,7 +148,11 @@ const OlMap = (props) => { }, [olMapGeoDataHost]) useEffect(() => { - if (patrolList.length && olMap) { + if (patrolList.length && olMap && tab == 'conserve') { + roadProjectList.forEach((d, index) => { + olMap.removeGeometryLayer('geometry_road_' + index) + }) + patrolList.forEach((d, index) => { console.log(d, index); olMap.addGeometryLayer({ @@ -204,10 +208,14 @@ const OlMap = (props) => { }); }); } - }, [patrolList, olMap]) + }, [patrolList, olMap, tab]) useEffect(() => { - if (roadProjectList.length && olMap) { + if (roadProjectList.length && olMap && tab == 'build') { + patrolList.forEach((d, index) => { + olMap.removeGeometryLayer('geometry_patrol_' + index) + }) + roadProjectList.forEach((d, index) => { olMap.addGeometryLayer({ features: [ @@ -248,11 +256,11 @@ const OlMap = (props) => { scale: 1, // 图标引用 }, }, - layerName: 'geometry_road_' + index + layerName: 'geometry_road_'// + index }); }); } - }, [roadProjectList, olMap]) + }, [roadProjectList, olMap, tab]) const isRoadProject = pointItem.report_type == 'road' return (