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}, {name:'水库监测',key:203}, {name:'防汛调度',key:205}, {name:'巡查维养',key:206}, ].map((item)=> <>
{ dispatch.map.setView(item.key) if(item.key===200){ const center = JSON.parse(sessionStorage.getItem('lastCenter')) if(center){ dispatch.runtime.setCameraTarget({ center: center, zoom: 15, pitch: 50, bearing: 0 }); } } }}>{item.name}
) }
:null }
) }