Commit 312aa015 authored by 皮倩雯's avatar 皮倩雯

fix: '管网预览代码回退'

parent 7f13dfa9
Pipeline #78909 passed with stages
/* eslint-disable no-unused-expressions */
import React, { useEffect, useState, useRef } from 'react'; import React, { useEffect, useState, useRef } from 'react';
import SiteModal from '@/components/Modal/SiteModa'; import SiteModal from '@/components/Modal/SiteModa';
import { Spin } from 'antd'; import { Input, Cascader, Button, message, Spin } from 'antd';
import {
gcj_decrypt,
exetent2AmapPoint,
lngLat2WebMercator,
plan2AMapbound,
webMercator2LngLat,
} from '@/utils/transformUtil';
import { GetAllConfig, GetMetaData } from '@/services/gis/gis'; import { GetAllConfig, GetMetaData } from '@/services/gis/gis';
import { ArcGISSceneMap } from '@wisdom-map/arcgismap'; import ReactJson from 'react-json-view';
import { tr } from 'voca';
const { Search } = Input;
const VectorPreviewModal = props => { const VectorPreviewModal = props => {
const { metaData } = props; const { metaData } = props;
const mapID = useRef();
const [currentMeta, setCurrentMeta] = useState(); const [currentMeta, setCurrentMeta] = useState();
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
useEffect(() => { useEffect(() => {
if (document.getElementById('map-container')) {
if (!mapID.current) {
//1.加载底图
let m = new window.AMap.Map('map-container');
mapID.current = m;
}
}
}, [props]);
useEffect(() => {
let map = mapID.current;
map && map.clearMap();
map && map.remove(map.getLayers());
setIsLoading(true); setIsLoading(true);
GetMetaData({ mapServerName: metaData?.GISServerProjectName }).then(res2 => { map &&
setIsLoading(false); GetMetaData({ mapServerName: metaData.GISServerProjectName }).then(res2 => {
if (res2 && res2.units) { setIsLoading(false);
const extent = res2.fullExtent; if (res2 && res2.units) {
if (extent.xmax < 100000000 && extent.xmax > 0) { setCurrentMeta(res2);
let str = `${extent.xmin},${extent.ymin},${extent.xmax},${extent.ymax}`; const layers = res2.layers || [];
console.log(str); const workspace = res2.mapName.split('_')[0];
debugger; const subLayers = layers
let mapsettings = { .filter(layer => layer.subLayerIds && layer.subLayerIds.length === 0)
layers: [ .map(layer => layer.name);
{ const paramLayers = `${workspace}:${subLayers.join(',')}`;
id: metaData?.GISServerProjectName, const params = {
title: metaData?.GISServerProjectName, LAYERS: paramLayers,
icon: '', VERSION: '1.1.1',
layerType: '', _site: '',
url: `/PandaGIS/MapServer/${metaData?.GISServerProjectName}`, };
opacity: '1.0', const wmsOption = {
showLegend: true, tileSize: 512,
visible: true, url: `${location.origin}/PandaGIS/MapServer/Export/${
useProxy: true, metaData.GISServerProjectName
proxyUrl: '', }/GeoServerProxy/wms`,
extent: str, blend: false,
baseLayer: '', params: params,
resolution: '', zooms: [2, 20],
origin: '',
tileMatrix: '',
wmtsUrl: '',
schemename: '',
roles: '',
areaName: '',
boundColor: '#86c8f8',
backgroundColor: '#000000',
boundWidth: '10px',
backgroundOpacity: '0.6',
basemaps: [
{
id: '高德地形',
title: '高德地形',
thumbnailUrl: 'images/thumbnail/thumbnail_1.jpg',
baseLayers: [
{
title: '高德地形',
icon: '',
layerType: 'amap-v',
url: '',
opacity: '1.0',
visible: false,
useProxy: false,
proxyUrl: '',
style: '',
extent: '',
baseLayer: '',
resolution: '',
origin: '',
tileMatrix: '',
levelStart: '',
levelEnd: '',
levelEndEnlarge: false,
},
],
},
],
levelStart: '',
},
],
}; };
setCurrentMeta(mapsettings); let wms = new window.AMap.TileLayer.WMS(wmsOption);
map.add(wms);
setIsLoading(true);
// wms.complete(() => {
// setIsLoading(false)
// })
wms.on('complete', () => {
setIsLoading(false);
});
const extent = res2.fullExtent;
if (extent.xmax < 100000000 && extent.xmax > 0) {
const a = webMercator2LngLat(extent.xmin, extent.ymin);
const b = webMercator2LngLat(extent.xmax, extent.ymax);
const southWest = new AMap.LngLat(a[0], a[1]);
const northEast = new AMap.LngLat(b[0], b[1]);
mapID.current.setBounds(new AMap.Bounds(southWest, northEast));
}
} }
} });
});
}, [metaData]); }, [metaData]);
const resetmap = () => {};
const getMapInfo = viewObject => { const getInitConfig = () => {};
console.log(viewObject);
};
const onSubmit = () => {}; const onSubmit = () => {};
return ( return (
<SiteModal <SiteModal
...@@ -102,14 +96,22 @@ const VectorPreviewModal = props => { ...@@ -102,14 +96,22 @@ const VectorPreviewModal = props => {
> >
<Spin spinning={isLoading}> <Spin spinning={isLoading}>
<div style={{ width: '1000px', height: '500px' }}> <div style={{ width: '1000px', height: '500px' }}>
{currentMeta && ( <div style={{ width: '1000px', height: '500px', position: 'absolute' }}>
<ArcGISSceneMap <div id="map-container" style={{ width: '1000px', height: '500px' }} />
getMapInfo={e => getMapInfo(e)} <div
config={currentMeta} style={{
client="sandbox" top: '10px',
widgets={[]} right: '10px',
/> position: 'absolute',
)} overflowY: 'scroll',
maxHeight: '480px',
maxWidth: '250px',
backgroundColor: 'white',
}}
>
{/* <ReactJson src={currentMeta} /> */}
</div>
</div>
</div> </div>
</Spin> </Spin>
</SiteModal> </SiteModal>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment