import { IconButton } from '@material-ui/core'; import { FirstPage, Language, LastPage, SaveAlt } from '@material-ui/icons'; import React, { useRef } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { Link } from 'react-router-dom'; import { hidePanels } from '../../../../models/map/selectors'; import { mgrHomePage } from '../../../../models/_/menu'; import { genLegend } from '../Legend/_'; import './Title.less'; import config from '../../../../config'; function downImg(url) { let a = document.createElement("a") let clickEvent = document.createEvent("MouseEvents"); a.setAttribute("href", url) a.setAttribute("download", '图片快照') a.setAttribute("target", '_blank') clickEvent.initEvent('click', true, true) a.dispatchEvent(clickEvent); } export default function Title() { const dispatch = useDispatch(); const inputRef = useRef(); const hp = useSelector(hidePanels); const layerVisible = useSelector(s => s.map.layerVisible); const doSearch = () => dispatch.map.openSearch(inputRef.current.value); const view = useSelector(s => s.map.view); const searchPressed = (e) => { if (e.keyCode === 13) { doSearch(); } } const showLayersDlg = () => { dispatch.runtime.setInfoDlg({ layerId: 'Layers' }); } const toggleHidePanels = () => { dispatch.map.setHidePanels(!hp); } const ExportImage = async () => { const map = window.__mapref; if (!map) { return; } const sc = map.getCanvas(); const { width, height } = sc; console.log(width, height); const c = document.createElement('canvas'); c.width = width; c.height = height; const ctx = c.getContext('2d'); ctx.fillStyle = '#000'; ctx.fillRect(0, 0, width, height); ctx.drawImage(sc, 0, 0); const legend = await genLegend(layerVisible); if (legend) { ctx.drawImage(legend.canvas, 0, 0, legend.width, legend.height, 32, 32, legend.width, legend.height); } const img = c.toDataURL('image/png'); downImg(img); } const fullMap = () => { dispatch.runtime.setHome(); } return (
图层
{ hp ? : }
{`${config.title}`}
管理平台
{ !hp && (
) }
{ view===301?
15
乡镇数量
16
水源地数量
221
水厂数量
33
服务人口
1026 万m³
年供水规模
:null } { (view===203||view===205||view===206)?
{ [ {name:'返回',key:200,icon:'返回.png',icon2:'返回.png'}, {name:'水库监测',key:203,icon:'水库.png',icon2:'水库2.png'}, {name:'防汛调度',key:205,icon:'防汛.png',icon2:'防汛2.png'}, {name:'巡查维养',key:206,icon:'巡查.png',icon2:'巡查2.png'}, ].map((item)=> <>
{ dispatch.map.setView(item.key) const map = window.__mapref; if (map) { const layer = map.getLayer('临时线') if (layer) { map.removeLayer('临时线'); map.removeSource('临时线'); } } if (item.key === 200) { const {lgtd,lttd} = JSON.parse(sessionStorage.getItem('lastCenter')) if(lgtd&<td){ dispatch.runtime.setCameraTarget({ center: [lgtd, lttd+0.005], zoom: 15, pitch: 50, bearing: 0 }); } } }}> { item.key===200? : }
) }
:null }
) }