Commit 55ffd0d3 authored by mayongxin's avatar mayongxin

perf:范围组件支持加载管网

parent aba3f653
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 { Input, Cascader, Button } from 'antd' import { Input, Cascader, Button } from 'antd'
import {gcj_decrypt,exetent2AmapPoint,lngLat2WebMercator} from '@/utils/transformUtil' import { gcj_decrypt, exetent2AmapPoint, lngLat2WebMercator } from '@/utils/transformUtil'
import { GetAllConfig, GetMetaData } from '@/services/platform/gis'
const { Search } = Input; const { Search } = Input;
const MapScope = props => { const MapScope = props => {
...@@ -9,10 +10,10 @@ const MapScope = props => { ...@@ -9,10 +10,10 @@ const MapScope = props => {
const [options, setOptions] = useState([]) const [options, setOptions] = useState([])
//const [mouseTool,setMouseTool] = useState(null) //const [mouseTool,setMouseTool] = useState(null)
const { confirmModal, stationId,distinct,extent } = props const { confirmModal, stationId, distinct, extent } = props
const [currentExtent, setCurrentExtent] = useState() const [currentExtent, setCurrentExtent] = useState()
const [isDistrict, setIsDistrict] = useState(false) const [isDistrict, setIsDistrict] = useState(false)
const [currentAreaName,setCurrentAreaName] = useState(null) const [currentAreaName, setCurrentAreaName] = useState(null)
const mapID = useRef(); const mapID = useRef();
const mouseToolID = useRef(); const mouseToolID = useRef();
...@@ -22,16 +23,60 @@ const MapScope = props => { ...@@ -22,16 +23,60 @@ const MapScope = props => {
if (document.getElementById("map-container")) { if (document.getElementById("map-container")) {
if (!mapID.current) { if (!mapID.current) {
//1.加载底图
let m = new window.AMap.Map('map-container'); let m = new window.AMap.Map('map-container');
mapID.current = m mapID.current = m
//2.加载管网配置
GetAllConfig().then(
res => {
if (res.IsSuccess == true) {
let pipenetCofig;
res.Result.map((item) => {
if (item.type == "pipenet") {
pipenetCofig = item
}
})
if (pipenetCofig) {
GetMetaData(pipenetCofig.servicename).then(
res2 => {
if (res2 && res2.units) {
const layers = res2.layers || [];
const workspace = res2.mapName.split('_')[0];
const subLayers = layers.filter(layer => layer.subLayerIds && layer.subLayerIds.length === 0).map(layer => layer.name);
const paramLayers = `${workspace}:${subLayers.join(',')}`;
const params = {
'LAYERS': paramLayers,
'VERSION': '1.1.1',
'_site':''
};
const wmsOption = {
tileSize: 512,
url: `${location.origin}/Cityinterface/rest/services/MapServer.svc/${pipenetCofig.servicename}/GeoServerProxy/wms`,
blend: false,
params: params,
zooms: [2, 20],
}
let wms = new window.AMap.TileLayer.WMS(wmsOption)
m.add(wms);
}
}
)
}
}
}
)
//3.组装高德支持的数据
} }
if (!mouseToolID.current) { if (!mouseToolID.current) {
let tool = new AMap.MouseTool(mapID.current) let tool = new AMap.MouseTool(mapID.current)
mouseToolID.current = tool mouseToolID.current = tool
} }
extent&&mapID.current.setCenter(exetent2AmapPoint(extent)) extent && mapID.current.setCenter(exetent2AmapPoint(extent))
distinct&&onCascderChange([distinct]) //distinct&&onCascderChange([distinct])
window.AMap.plugin('AMap.DistrictSearch', function () { window.AMap.plugin('AMap.DistrictSearch', function () {
let districtSearch = new AMap.DistrictSearch({ let districtSearch = new AMap.DistrictSearch({
...@@ -51,7 +96,7 @@ const MapScope = props => { ...@@ -51,7 +96,7 @@ const MapScope = props => {
} }
}, [props]) }, [props])
const resetmap = ()=>{ const resetmap = () => {
} }
...@@ -59,7 +104,7 @@ const MapScope = props => { ...@@ -59,7 +104,7 @@ const MapScope = props => {
} }
const onSubmit = () => { const onSubmit = () => {
confirmModal && confirmModal(currentExtent,currentAreaName) confirmModal && confirmModal(currentExtent, currentAreaName)
let mouseTool = mouseToolID.current; let mouseTool = mouseToolID.current;
mouseTool.close(true) mouseTool.close(true)
let map = mapID.current let map = mapID.current
...@@ -117,9 +162,9 @@ const MapScope = props => { ...@@ -117,9 +162,9 @@ const MapScope = props => {
district.search(`${value[value.length - 1]}`, function (status, result) { district.search(`${value[value.length - 1]}`, function (status, result) {
// 获取朝阳区的边界信息 // 获取朝阳区的边界信息
let bounds = result.districtList[0].boundaries let bounds = result.districtList[0].boundaries
let polygons = [] let polygons = []
if (bounds) { if (bounds) {
for (let i = 0, l = bounds.length; i < l; i++) { for (let i = 0, l = bounds.length; i < l; i++) {
...@@ -136,7 +181,7 @@ const MapScope = props => { ...@@ -136,7 +181,7 @@ const MapScope = props => {
} }
// 地图自适应 // 地图自适应
map.setFitView() map.setFitView()
setCurrentAreaName(value[value.length-1]) setCurrentAreaName(value[value.length - 1])
setIsDistrict(true) setIsDistrict(true)
} }
}) })
......
...@@ -280,7 +280,6 @@ const UserModal = props => { ...@@ -280,7 +280,6 @@ const UserModal = props => {
})} })}
> >
<Row align="middle"> <Row align="middle">
<Col span={1}>搜索</Col>
<Col span={8}> <Col span={8}>
<Search <Search
allowClear allowClear
......
import { get, post, PUBLISH_SERVICE, CITY_SERVICE } from '@/services/index';
//1.获取全部地图方案配置
export const GetAllConfig = param =>
get(`${CITY_SERVICE}/OMS.svc/GetAllConfig`, param);
//2.获取元数据
export const GetMetaData = param =>
get(`${CITY_SERVICE}/MapServer.svc/${param}`);
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