import React, { useEffect, useReducer, useRef, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import DiQiu from '../img/DiQiu.png' import ZhongXin from '../img/ZhongXin.png' import Shouqi2 from '../img/shouqi2.png' import Zhankai2 from '../img/zhankai2.png' export default function Btn({showPanels,setShowPanels}) { const [open, setOpen] = useState(false) const getLayerVisible = (s) => s.map.layerVisible; const mode = useSelector((s) => s.map.mode); const layerVisible = useSelector(getLayerVisible); let mapObj = useSelector((s) => s.map.map); const dispatch = useDispatch() //收起\展开 const collapseExpand = () => { setShowPanels(!showPanels) } //图层控制 const showLayers = () => { setOpen(!open) } const onClose = () => { setOpen(false) } //还原地图位置 const reduction = () => { dispatch.runtime.setHome() } //影像图btn const yxtBtn = () =>{ dispatch.map.setMode('2d'); dispatch.map.setLayerVisible({ ['OfflineMap']: false }); dispatch.map.setLayerVisible({ ['SatelliteImage']: true }); //卫星图打开河流面很丑,所以关掉 mapObj && mapObj.getLayers().getArray().forEach((layer)=> { if(layer.values_.name === "HLLayer"||layer.values_.name === "HL2Layer"){ layer.setVisible(false); } if(layer.values_.name === "HLLayer2"){ layer.setVisible(true); } }); } //矢量图btn const sltBtn = ()=>{ dispatch.map.setMode('2d'); dispatch.map.setLayerVisible({ ['SatelliteImage']: false }); dispatch.map.setLayerVisible({ ['OfflineMap']: true }); mapObj && mapObj.getLayers().getArray().forEach((layer)=> { if(layer.values_.name === "HLLayer"||layer.values_.name === "HL2Layer"){ layer.setVisible(true); } if(layer.values_.name === "HLLayer2"){ layer.setVisible(false); } }); } //3Dbtn const btn3d = ()=>{ dispatch.map.setMode('3d'); } return (
影像图