import React, { useEffect, useState } from 'react' import { useLocation } from 'react-router' import { useDispatch, useSelector } from 'react-redux' import { Drawer } from 'antd' import './index.less' import MapCtrl from './MapCtrl' import HomePanelsLayoutPage from './homePanelsLayoutPage' import LayersPage from '../Home/dlg/LayersDlg' import Shouqi2 from './img/shouqi2.png' import Zhankai2 from './img/zhankai2.png' import DiQiu from './img/DiQiu.png' import ZhongXin from './img/ZhongXin.png' import Ysgzq from '../ysgzq/ssyq' import Sssq from '../ysgzq/sssq' import Yqz from '../fxzb/jczw/yqz/index.js' import Sqz from '../fxzb/jczw/sqz/index.js' import Ddxsfx from '../fxdd/dqxsfx' // import Tqyb from '../fxdd/tqyb' import Fhxs from './fhxs' import Tqyb from './tqyb' import Tuli from './img/tuli.png' import ysgzqTuli from './img/ysgzqTuli.png' const HomePage = () => { const getLayerVisible = (s:any) => s.map.layerVisible; let mapObj = useSelector((s:any) => s.map.map); const layerVisible = useSelector(getLayerVisible); const location = useLocation() const dispatch = useDispatch() const pathname = location.pathname const [showPanels, setShowPanels] = useState(true) const [open, setOpen] = useState(false) //收起\展开 const collapseExpand = () => { setShowPanels(!showPanels) } //还原地图位置 const reduction = () => { dispatch.runtime.setHome() } //图层控制 const showLayers = () => { setOpen(!open) } const onClose = () => { setOpen(false) } useEffect(() => { // if (pathname !== '/mgr/home') { // dispatch.map.setLayerVisible({ ShuiKuLayer: false }) // dispatch.map.setZhongxingSk(true) // } else { // dispatch.map.setLayerVisible({ ShuiKuLayer: true }) // dispatch.map.setZhongxingSk(true) // } }, [pathname]) useEffect(() => { // if (pathname == '/mgr/home' && !showPanels) { // dispatch.map.setZhongxingSk(true) // dispatch.map.setLayerVisible({ AdcdLayer: true }) // dispatch.map.setLayerVisible({ ShuiKuLayer: true }) // } }, [showPanels]) return (
{/* 控制按钮 */}
{showPanels ? ( ) : ( )}
{/*
{ dispatch.runtime.setIn(); }}>
{ dispatch.runtime.setOut(); }}>
*/} {/*
*/}
{ dispatch.map.setLayerVisible({ ['OfflineMap']: false }); dispatch.map.setLayerVisible({ ['SatelliteImage']: true }); //卫星图打开河流面很丑,所以关掉 mapObj && mapObj.getLayers().getArray().forEach((layer:any)=> { if(layer.values_.name === "HLLayer"||layer.values_.name === "HL2Layer"){ layer.setVisible(false); } if(layer.values_.name === "HLLayer2"){ layer.setVisible(true); } }); }}> 影像图
{ dispatch.map.setLayerVisible({ ['SatelliteImage']: false }); dispatch.map.setLayerVisible({ ['OfflineMap']: true }); mapObj && mapObj.getLayers().getArray().forEach((layer:any)=> { if(layer.values_.name === "HLLayer"||layer.values_.name === "HL2Layer"){ layer.setVisible(true); } if(layer.values_.name === "HLLayer2"){ layer.setVisible(false); } }); }}> 矢量图
{/* 地图 */} {/*首页面板*/} {pathname === '/mgr/home' ? ( ) : null} {/*防汛调度-防洪形势*/} {pathname === '/mgr/fxzb/fhxs' ? ( ) : null} {/*防汛调度-天气预报*/} {pathname === '/mgr/fxzb/tqyb' ? ( ) : null} {/*雨水工灾情面板-雨情*/} {pathname === '/mgr/ysgzq/ssyq' ? (
) : null} {/*雨水工灾情面板-水情*/} {pathname === '/mgr/ysgzq/sssq' ? (
) : null} {/*防汛调度面板-当前形势*/} {pathname === '/mgr/fxdd/dqxsfx' ? (
) : null} {/*防汛调度-天气预报面板*/} {/* {pathname === '/mgr/fxdd/tqyb' ? (
) : null} */}
) } export default HomePage