import React, { useEffect, useMemo, useState } from 'react';
import { Switch, Collapse,Table, TableContainer, TableBody,TableHead, TableRow, TableSortLabel } from '@material-ui/core/index'
import DpTableCell from '../../../../layouts/mui/DpTableCell';
import DpTableRow from '../../../../layouts/mui/DpTableRow';
import { parseGeoJSON } from "../../../../utils/tools";
import { SkRealPromise } from "../../../../models/_/real";
import CollapsePage from './collapsePage'
import { useDispatch } from 'react-redux';
import CountPage from './countPage'
function Page({jbqkKey}) {
const [skType,setSkType] = useState('')
const [skData,setSkData] = useState([])
const dispatch = useDispatch()
const flyTo = (row)=>{
const { lgtd, lttd } = row;
if (lgtd && lttd) {
// dispatch.runtime.setFeaturePop({ type: 'adcd', properties: row, coordinates: [row.lgtd, row.lttd] });
dispatch.runtime.setCameraTarget({
center: [lgtd, lttd],//+0.003
zoom: 15,
pitch: 50,
bearing: 0
});
}
}
useEffect(()=>{
getSkData()
return ()=>{
const map = window.__mapref;
const layer = map.getLayer('临时水库')
if(layer){
map.removeLayer('临时水库');
map.removeSource('临时水库');
}
}
},[])
const getSkData = async()=>{
const data = await SkRealPromise.get();
setSkData(data)
}
const setSkLayer = (data=[])=>{
const map = window.__mapref;
const layer = map.getLayer('临时水库')
if(layer){
map.removeLayer('临时水库');
map.removeSource('临时水库');
}
if(data.length===0){return}
map.addLayer({
'id': '临时水库',//+new Date().getTime(),
'type': 'symbol',
'source': {
'type': 'geojson',
'data': {
'type': 'FeatureCollection',
'features': [],
},
},
'layout': {
// 'icon-allow-overlap': true,
// 'text-allow-overlap': true,
'icon-image': '水库', // 从properties中动态读取icon字段
'icon-size': [
'interpolate', ['linear'], ['zoom'],
10, 0.8,
14, 0.8,
],
'text-size': [
'interpolate', ['linear'], ['zoom'],
5, 10,
14, 14,
],
'text-font': ['Roboto Black'],
'text-field': [
'step',
['zoom'],
'',
8, ['get', 'stnm']
],
'text-anchor': 'top',
'text-offset': [0, 1],
},
'paint': {
'text-color': '#fff'
},
'visibility': 'visible',
});
map.getSource('临时水库').setData(parseGeoJSON(data))
}
return (
<>