|
@ -6,14 +6,20 @@ import moment from 'moment'; |
|
|
import { OlMapRequest } from '$utils' |
|
|
import { OlMapRequest } from '$utils' |
|
|
|
|
|
|
|
|
const OlMap = (props) => { |
|
|
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 [olMapOpenData, setOlMapOpenData] = useState([]) |
|
|
const [olMap, setOlMap] = useState() |
|
|
const [olMap, setOlMap] = useState() |
|
|
const [pointItem, setPointItem] = useState({}) |
|
|
const [pointItem, setPointItem] = useState({}) |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
|
|
|
setOlMapOpenData([]) |
|
|
}, []) |
|
|
setPointItem({}) |
|
|
|
|
|
if (olMap) { |
|
|
|
|
|
olMap.closeOverlay('clickOpen') |
|
|
|
|
|
olMap.closeOverlay('pointClickOpen') |
|
|
|
|
|
olMap.removeGeometryLayer('geometry0') |
|
|
|
|
|
} |
|
|
|
|
|
}, [tab]) |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
if (olMapGeoDataHost) { |
|
|
if (olMapGeoDataHost) { |
|
@ -148,7 +154,11 @@ const OlMap = (props) => { |
|
|
}, [olMapGeoDataHost]) |
|
|
}, [olMapGeoDataHost]) |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
if (patrolList.length && olMap) { |
|
|
if (patrolList.length && olMap && tab == 'conserve') { |
|
|
|
|
|
roadProjectList.forEach((d, index) => { |
|
|
|
|
|
olMap.removeGeometryLayer('geometry_road_' + index) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
patrolList.forEach((d, index) => { |
|
|
patrolList.forEach((d, index) => { |
|
|
console.log(d, index); |
|
|
console.log(d, index); |
|
|
olMap.addGeometryLayer({ |
|
|
olMap.addGeometryLayer({ |
|
@ -164,7 +174,7 @@ const OlMap = (props) => { |
|
|
setPointItem(d) |
|
|
setPointItem(d) |
|
|
olMap.addOverlay('pointClickOpen', { |
|
|
olMap.addOverlay('pointClickOpen', { |
|
|
id: 'pointClickOpen', |
|
|
id: 'pointClickOpen', |
|
|
offset: [0, 25], // 偏移
|
|
|
offset: [0, 4], // 偏移
|
|
|
position: [d.longitude, d.latitude], // 坐标
|
|
|
position: [d.longitude, d.latitude], // 坐标
|
|
|
autoPan: true, |
|
|
autoPan: true, |
|
|
autoPanMargin: 100, |
|
|
autoPanMargin: 100, |
|
@ -178,9 +188,8 @@ const OlMap = (props) => { |
|
|
], |
|
|
], |
|
|
style: { |
|
|
style: { |
|
|
icon: { |
|
|
icon: { |
|
|
src: '/assets/images/worker.png', |
|
|
src: '/assets/images/gis/pointer.png', |
|
|
// anchor: [0.5, 1],
|
|
|
scale: 1, // 图标引用
|
|
|
scale: 0.08, // 图标引用
|
|
|
|
|
|
}, |
|
|
}, |
|
|
// stroke: { width: 1, color: '#ffff00' },
|
|
|
// stroke: { width: 1, color: '#ffff00' },
|
|
|
// circle: {
|
|
|
// circle: {
|
|
@ -191,9 +200,8 @@ const OlMap = (props) => { |
|
|
}, |
|
|
}, |
|
|
selectStyle: { |
|
|
selectStyle: { |
|
|
icon: { |
|
|
icon: { |
|
|
src: '/assets/images/worker.png', |
|
|
src: '/assets/images/gis/pointer.png', |
|
|
// anchor: [0.5, 1],
|
|
|
scale: 1, // 图标引用
|
|
|
scale: 0.08, // 图标引用
|
|
|
|
|
|
}, |
|
|
}, |
|
|
// circle: {
|
|
|
// circle: {
|
|
|
// radius: 16, // 直径
|
|
|
// radius: 16, // 直径
|
|
@ -206,10 +214,14 @@ const OlMap = (props) => { |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
}, [patrolList, olMap]) |
|
|
}, [patrolList, olMap, tab]) |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
if (roadProjectList.length && olMap) { |
|
|
if (roadProjectList.length && olMap && tab == 'build') { |
|
|
|
|
|
patrolList.forEach((d, index) => { |
|
|
|
|
|
olMap.removeGeometryLayer('geometry_patrol_' + index) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
roadProjectList.forEach((d, index) => { |
|
|
roadProjectList.forEach((d, index) => { |
|
|
olMap.addGeometryLayer({ |
|
|
olMap.addGeometryLayer({ |
|
|
features: [ |
|
|
features: [ |
|
@ -224,7 +236,7 @@ const OlMap = (props) => { |
|
|
setPointItem(d) |
|
|
setPointItem(d) |
|
|
olMap.addOverlay('pointClickOpen', { |
|
|
olMap.addOverlay('pointClickOpen', { |
|
|
id: 'pointClickOpen', |
|
|
id: 'pointClickOpen', |
|
|
offset: [0, 25], // 偏移
|
|
|
offset: [0, 4], // 偏移
|
|
|
position: [d.longitude, d.latitude], // 坐标
|
|
|
position: [d.longitude, d.latitude], // 坐标
|
|
|
// position: [115.944220000000, 28.545380000000],
|
|
|
// position: [115.944220000000, 28.545380000000],
|
|
|
autoPan: true, |
|
|
autoPan: true, |
|
@ -240,21 +252,21 @@ const OlMap = (props) => { |
|
|
], |
|
|
], |
|
|
style: { |
|
|
style: { |
|
|
icon: { |
|
|
icon: { |
|
|
src: '/assets/images/worker.png', |
|
|
src: '/assets/images/gis/pointer.png', |
|
|
scale: 0.08, // 图标引用
|
|
|
scale: 1, // 图标引用
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
selectStyle: { |
|
|
selectStyle: { |
|
|
icon: { |
|
|
icon: { |
|
|
src: '/assets/images/worker.png', |
|
|
src: '/assets/images/gis/pointer.png', |
|
|
scale: 0.08, // 图标引用
|
|
|
scale: 1, // 图标引用
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
layerName: 'geometry_road_' + index |
|
|
layerName: 'geometry_road_' + index |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
}, [roadProjectList, olMap]) |
|
|
}, [roadProjectList, olMap, tab]) |
|
|
|
|
|
|
|
|
const isRoadProject = pointItem.report_type == 'road' |
|
|
const isRoadProject = pointItem.report_type == 'road' |
|
|
return ( |
|
|
return ( |
|
@ -301,16 +313,23 @@ const OlMap = (props) => { |
|
|
<div style={{ width: "50%", height: "100%", }}> |
|
|
<div style={{ width: "50%", height: "100%", }}> |
|
|
{ |
|
|
{ |
|
|
pointItem.id ? |
|
|
pointItem.id ? |
|
|
<Hua shuzu={[{ |
|
|
<Hua key={pointItem.id} shuzu={ |
|
|
"imgs": pointItem.conserve_after_pic ? |
|
|
isRoadProject ? |
|
|
pointItem.conserve_after_pic[0] : "" |
|
|
[{ |
|
|
}, { |
|
|
"imgs": pointItem.scene_pic && pointItem.scene_pic.length ? |
|
|
"imgs": pointItem.conserve_before_pic ? |
|
|
pointItem.scene_pic[0] : "" |
|
|
pointItem.conserve_before_pic[0] : "" |
|
|
}] : |
|
|
}, { |
|
|
[{ |
|
|
"imgs": pointItem.conserve_underway_pic ? |
|
|
"imgs": pointItem.conserve_after_pic ? |
|
|
pointItem.conserve_underway_pic[0] : "" |
|
|
pointItem.conserve_after_pic[0] : "" |
|
|
}]} /> |
|
|
}, { |
|
|
|
|
|
"imgs": pointItem.conserve_before_pic ? |
|
|
|
|
|
pointItem.conserve_before_pic[0] : "" |
|
|
|
|
|
}, { |
|
|
|
|
|
"imgs": pointItem.conserve_underway_pic ? |
|
|
|
|
|
pointItem.conserve_underway_pic[0] : "" |
|
|
|
|
|
}]} |
|
|
|
|
|
/> |
|
|
: '' |
|
|
: '' |
|
|
} |
|
|
} |
|
|
</div> |
|
|
</div> |
|
|