点位创建
This commit is contained in:
parent
8d1b54517d
commit
691a59a84b
@ -15,7 +15,9 @@
|
|||||||
"@ant-design/icons": "^4.7.0",
|
"@ant-design/icons": "^4.7.0",
|
||||||
"@ant-design/pro-components": "^2.0.1",
|
"@ant-design/pro-components": "^2.0.1",
|
||||||
"@antv/l7": "^2.12.0",
|
"@antv/l7": "^2.12.0",
|
||||||
|
"@antv/l7-draw": "^3.1.0",
|
||||||
"@antv/l7-maps": "^2.12.0",
|
"@antv/l7-maps": "^2.12.0",
|
||||||
|
"@antv/l7plot": "^0.5.7",
|
||||||
"@umijs/max": "^4.0.40",
|
"@umijs/max": "^4.0.40",
|
||||||
"antd": "^5.0.0",
|
"antd": "^5.0.0",
|
||||||
"axios": "^1.3.5",
|
"axios": "^1.3.5",
|
||||||
|
@ -7,6 +7,7 @@ import Header from '../../components/Header/index.js';
|
|||||||
import { createPoint, queryUserLayers } from '../../api';
|
import { createPoint, queryUserLayers } from '../../api';
|
||||||
|
|
||||||
import { GaodeMap ,Scene, Heatmap, PolygonLayer, Marker, MarkerLayer, Popup } from '@antv/l7';
|
import { GaodeMap ,Scene, Heatmap, PolygonLayer, Marker, MarkerLayer, Popup } from '@antv/l7';
|
||||||
|
import { DrawPoint, DrawEvent } from '@antv/l7-draw';
|
||||||
|
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
@ -51,9 +52,9 @@ class BaseMap extends React.Component{
|
|||||||
markerLayerList: [],
|
markerLayerList: [],
|
||||||
isModalOpen: false,
|
isModalOpen: false,
|
||||||
selectLayerList: [],
|
selectLayerList: [],
|
||||||
pointAdd: {
|
pointAdd: {},
|
||||||
|
pointDrawer: null,
|
||||||
},
|
newPointLocation: '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
startLoading = () => {
|
startLoading = () => {
|
||||||
@ -82,8 +83,16 @@ class BaseMap extends React.Component{
|
|||||||
zoom: 3
|
zoom: 3
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
const drawer = new DrawPoint(scene, {});
|
||||||
|
let newPointLocation = '';
|
||||||
|
drawer.disable();
|
||||||
|
drawer.on(DrawEvent.Add, (newPoint) => {
|
||||||
|
newPointLocation = newPoint.geometry.coordinates.toString();
|
||||||
|
this.showModal(newPointLocation);
|
||||||
|
})
|
||||||
this.setState({
|
this.setState({
|
||||||
map: scene
|
map: scene,
|
||||||
|
pointDrawer: drawer,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +106,7 @@ class BaseMap extends React.Component{
|
|||||||
|
|
||||||
//根据cityname、adcode、citycode设置地图位置
|
//根据cityname、adcode、citycode设置地图位置
|
||||||
gotoCity = (data) => {
|
gotoCity = (data) => {
|
||||||
this.state.map.removeAllMarkers();
|
this.state.map.removeAllMarkers && this.state.map.removeAllMarkers();
|
||||||
let zoom = data.zoom || 10;
|
let zoom = data.zoom || 10;
|
||||||
let lng = data.len || 116.405285;
|
let lng = data.len || 116.405285;
|
||||||
let lat = data.lat || 39.904989;
|
let lat = data.lat || 39.904989;
|
||||||
@ -524,9 +533,14 @@ class BaseMap extends React.Component{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enableDrawPoint = () => {
|
||||||
|
this.state.pointDrawer.enable();
|
||||||
|
}
|
||||||
|
|
||||||
//弹出框事件
|
//弹出框事件
|
||||||
showModal = () => {
|
showModal = (newPointLocation) => {
|
||||||
queryUserLayers().then((e) => {debugger
|
queryUserLayers().then((e) => {
|
||||||
let data = e.data;
|
let data = e.data;
|
||||||
let selectLayerList = [];
|
let selectLayerList = [];
|
||||||
for (var i in data) {
|
for (var i in data) {
|
||||||
@ -538,6 +552,7 @@ class BaseMap extends React.Component{
|
|||||||
this.setState({
|
this.setState({
|
||||||
isModalOpen: true,
|
isModalOpen: true,
|
||||||
selectLayerList: selectLayerList,
|
selectLayerList: selectLayerList,
|
||||||
|
newPointLocation: newPointLocation,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -548,12 +563,9 @@ class BaseMap extends React.Component{
|
|||||||
"note": this.state.pointAdd.note,
|
"note": this.state.pointAdd.note,
|
||||||
"address": this.state.pointAdd.address,
|
"address": this.state.pointAdd.address,
|
||||||
"cityAdcode": this.state.cityAdcode,
|
"cityAdcode": this.state.cityAdcode,
|
||||||
// "cityName": "string",
|
|
||||||
"districtAdcode": this.state.districtAdcode,
|
"districtAdcode": this.state.districtAdcode,
|
||||||
// "districtName": "string",
|
"location": this.state.newPointLocation,
|
||||||
// "location": "string",
|
|
||||||
"provinceAdcode": this.state.provinceAdcode,
|
"provinceAdcode": this.state.provinceAdcode,
|
||||||
// "provinceName": "string",
|
|
||||||
}).then((e) => {
|
}).then((e) => {
|
||||||
if (e.success) {
|
if (e.success) {
|
||||||
message.success(e.message || '成功!');
|
message.success(e.message || '成功!');
|
||||||
@ -566,6 +578,7 @@ class BaseMap extends React.Component{
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
handleCancel = () => {
|
handleCancel = () => {
|
||||||
|
this.state.pointDrawer.disable();
|
||||||
this.setState({
|
this.setState({
|
||||||
isModalOpen: false
|
isModalOpen: false
|
||||||
});
|
});
|
||||||
@ -573,7 +586,7 @@ class BaseMap extends React.Component{
|
|||||||
onLayerNameChange = (e) => {
|
onLayerNameChange = (e) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
pointAdd: {
|
pointAdd: {
|
||||||
"layerId": this.state.pointAdd.layerId,
|
"layerId": e,
|
||||||
"name": this.state.pointAdd.name,
|
"name": this.state.pointAdd.name,
|
||||||
"note": this.state.pointAdd.note,
|
"note": this.state.pointAdd.note,
|
||||||
"address": this.state.pointAdd.address,
|
"address": this.state.pointAdd.address,
|
||||||
@ -584,7 +597,7 @@ class BaseMap extends React.Component{
|
|||||||
this.setState({
|
this.setState({
|
||||||
pointAdd: {
|
pointAdd: {
|
||||||
"layerId": this.state.pointAdd.layerId,
|
"layerId": this.state.pointAdd.layerId,
|
||||||
"name": this.state.pointAdd.name,
|
"name": e.currentTarget.value,
|
||||||
"note": this.state.pointAdd.note,
|
"note": this.state.pointAdd.note,
|
||||||
"address": this.state.pointAdd.address,
|
"address": this.state.pointAdd.address,
|
||||||
},
|
},
|
||||||
@ -596,7 +609,7 @@ class BaseMap extends React.Component{
|
|||||||
"layerId": this.state.pointAdd.layerId,
|
"layerId": this.state.pointAdd.layerId,
|
||||||
"name": this.state.pointAdd.name,
|
"name": this.state.pointAdd.name,
|
||||||
"note": this.state.pointAdd.note,
|
"note": this.state.pointAdd.note,
|
||||||
"address": this.state.pointAdd.address,
|
"address": e.currentTarget.value,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -605,7 +618,7 @@ class BaseMap extends React.Component{
|
|||||||
pointAdd: {
|
pointAdd: {
|
||||||
"layerId": this.state.pointAdd.layerId,
|
"layerId": this.state.pointAdd.layerId,
|
||||||
"name": this.state.pointAdd.name,
|
"name": this.state.pointAdd.name,
|
||||||
"note": this.state.pointAdd.note,
|
"note": e.currentTarget.value,
|
||||||
"address": this.state.pointAdd.address,
|
"address": this.state.pointAdd.address,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -654,7 +667,7 @@ class BaseMap extends React.Component{
|
|||||||
{/* 图层数据显示 */}
|
{/* 图层数据显示 */}
|
||||||
<LayerData ref="getLayerDataFun" getLayerPoints = {this.getLayerPoints} getLayerShapes = {this.getLayerShapes}/>
|
<LayerData ref="getLayerDataFun" getLayerPoints = {this.getLayerPoints} getLayerShapes = {this.getLayerShapes}/>
|
||||||
<div className={styles.btnRightWrap}>
|
<div className={styles.btnRightWrap}>
|
||||||
<Button type="primary" className={styles.btnRight} onClick={this.showModal}>点位创建</Button>
|
<Button type="primary" className={styles.btnRight} onClick={this.enableDrawPoint}>点位创建</Button>
|
||||||
<Modal title="点位创建" open={this.state.isModalOpen} onOk={this.handleOk} onCancel={this.handleCancel} className='add-point-modal'>
|
<Modal title="点位创建" open={this.state.isModalOpen} onOk={this.handleOk} onCancel={this.handleCancel} className='add-point-modal'>
|
||||||
<Form name='base' id='add-point-form' onFinish={this.handleOk}>
|
<Form name='base' id='add-point-form' onFinish={this.handleOk}>
|
||||||
<Form.Item label="选择自定义图层"
|
<Form.Item label="选择自定义图层"
|
||||||
|
Loading…
Reference in New Issue
Block a user