Browse Source

地图嵌入

master
wenlele 2 years ago
parent
commit
c0d99bb401
  1. 6
      api/log/development.log
  2. 35
      web/client/index.html
  3. 63
      web/client/src/sections/projectRegime/components/pointModel.js
  4. 61
      web/client/src/sections/projectRegime/components/projectAddModel.js
  5. 27
      web/log/development.txt

6
api/log/development.log

@ -4162,3 +4162,9 @@ notNull Violation: PatrolPlan.patrolCount cannot be null
2023-01-30 16:47:16.531 - debug: [FS-LOGGER] Init.
2023-01-30 16:47:16.660 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-01-30 16:47:16.661 - info: [FS-AUTH] Inject auth and api mv into router.
2023-01-30 17:12:59.959 - debug: [FS-LOGGER] Init.
2023-01-30 17:13:00.144 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-01-30 17:13:00.144 - info: [FS-AUTH] Inject auth and api mv into router.
2023-01-30 17:16:09.126 - debug: [FS-LOGGER] Init.
2023-01-30 17:16:09.250 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-01-30 17:16:09.250 - info: [FS-AUTH] Inject auth and api mv into router.

35
web/client/index.html

@ -2,28 +2,27 @@
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="shortcut icon" href="/assets/images/logo.png">
<link rel="stylesheet" type="text/css" href="/assets/font_sc/iconfont.css">
<script
src="https://webapi.amap.com/maps?v=2.0&key=00f9a29dedcdbd8befec3dfe0cef5003&plugin=AMap.Adaptor,AMap.Scale,AMap.ToolBar,AMap.DistrictSearch,AMap.Geocoder,AMap.CustomLayer,Map3D,ElasticMarker"></script>
<script src="https://webapi.amap.com/loca?v=2.0.0&key=00f9a29dedcdbd8befec3dfe0cef5003"></script>
<meta charset="UTF-8">
<title></title>
<link rel="shortcut icon" href="/assets/images/logo.png">
<link rel="stylesheet" type="text/css" href="/assets/font_sc/iconfont.css">
<script
src="https://webapi.amap.com/maps?v=2.0&key=862a5f37e751bdaeb31130b49bc82e62&plugin=AMap.AutoComplete,AMap.PlaceSearch"></script>
<!-- <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script> -->
</head>
<body>
<script>
window.less = {
async: false,
env: 'production'
};
</script>
<div id='App'></div>
<script type="text/javascript" src="http://localhost:5901/client/build/vendor.js"></script>
<script type="text/javascript" src="http://localhost:5901/client/build/app.js"></script>
<script
src="https://webapi.amap.com/maps?v=2.0&key=862a5f37e751bdaeb31130b49bc82e62&plugin=AMap.Adaptor,AMap.Scale,AMap.ToolBar,AMap.DistrictSearch,AMap.Geocoder,AMap.CustomLayer"></script>
<script>
window.less = {
async: false,
env: 'production'
};
</script>
<div id='App'></div>
<script type="text/javascript" src="http://localhost:5901/client/build/vendor.js"></script>
<script type="text/javascript" src="http://localhost:5901/client/build/app.js"></script>
</body>
</html>

63
web/client/src/sections/projectRegime/components/pointModel.js

@ -1,5 +1,6 @@
import React, { useState } from 'react';
import { Button, Form, Input, Modal, Select, DatePicker } from 'antd';
import { EnvironmentTwoTone } from '@ant-design/icons';
const { TextArea } = Input;
import { connect } from 'react-redux';
import Uploads from '$components/Uploads';
@ -9,10 +10,46 @@ import moment from 'moment';
const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, qrCodeId }) => {
const { projectRegime } = actions
const [showBaiduMap, setShowBaiduMap] = useState(false)
const [form] = Form.useForm();
useEffect(() => {
// console.log(modelData);
if (modelData?.longitude && modelData?.latitude) {
form.setFieldValue('longitude', modelData?.longitude)
form.setFieldValue('latitude', modelData?.latitude)
}
var map = new AMap.Map('container', {
resizeEnable: true, //是否监控地图容器尺寸变化
zoom: 11, //初始化地图层级
center: [116.397428, 39.90923] //初始化地图中心点
});
var autoOptions = {
input: "tipinput"
};
AMap.plugin(['AMap.PlaceSearch', 'AMap.AutoComplete', 'AMap.Geocoder'], () => {
var auto = new AMap.AutoComplete(autoOptions);
var placeSearch = new AMap.PlaceSearch({
map: map
}); //构造地点查询类
function select (e) {
if (e) {
placeSearch.setCity(e.poi.adcode);
placeSearch.search(e.poi.name, function (status, result) {
form.setFieldValue('longitude', result.poiList.pois[0].location.lat)
form.setFieldValue('latitude', result.poiList.pois[0].location.lng)
}) //关键字查询查询
}
}
auto.on("select", select);//注册监听,当选中某条记录时会触发
map.on('click', function (e) { //点击地图获取经纬度
form.setFieldValue('longitude', e.lnglat.lat)
form.setFieldValue('latitude', e.lnglat.lng)
});
});
}, [])
@ -54,9 +91,9 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, q
>
<Input placeholder="请输入点位名称" allowClear />
</Form.Item>
<div style={{}}>
<div style={{position: 'relative'}}>
{/* /^\d+$|^\d*\.\d+$/g */}
<Form.Item label="所在地区:" labelCol={{ span: 11 }} labelAlign='right' name="longitude" initialValue={modelData?.longitude} style={{ display: 'inline-block', width: 'calc(60% - 30px)', }}
<Form.Item label="所在地区:" labelCol={{ span: 11 }} labelAlign='right' name="longitude" style={{ display: 'inline-block', width: 'calc(60% - 30px)', }}
rules={[{ required: true, message: '', },{
validator: (rule, value, callback) => {
const sjh = /^\d+$|^\d*\.\d+$/g;
@ -74,7 +111,7 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, q
<Input placeholder="经度支持数字" />
</Form.Item>
~
<Form.Item name="latitude" initialValue={modelData?.latitude} style={{ display: 'inline-block', width: 'calc(40% + 15px)', }}
<Form.Item name="latitude" style={{ display: 'inline-block', width: 'calc(40% + 15px)', }}
rules={[{ required: true, message: '', },{
validator: (rule, value, callback) => {
const sjh = /^\d+$|^\d*\.\d+$/g;
@ -91,7 +128,25 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, q
>
<Input placeholder="维度支持数字" />
</Form.Item>
<EnvironmentTwoTone style={{ position: 'absolute', top: 5, right: 27, fontSize: 22 }} onClick={() => {
setShowBaiduMap(true)
}} />
</div>
<Form.Item
label={"地址"}
name='location'
style={showBaiduMap ? { display: 'block' } : { display: 'none' }}
>
<Input id="tipinput" />
</Form.Item>
<Form.Item
label="地图"
name='map'
style={showBaiduMap ? { display: 'block' } : { display: 'none' }}
>
<div id="container" style={{ width: '100%', height: '425px', marginBottom: '15px' }}></div>
</Form.Item>
<Form.Item name='describe' label="描述"
initialValue={modelData?.describe}
rules={[{ required: true, message: '请输入描述内容', },]}>

61
web/client/src/sections/projectRegime/components/projectAddModel.js

@ -1,5 +1,6 @@
import React, { useState } from 'react';
import { Button, Form, Input, Modal, Select, DatePicker } from 'antd';
import { Button, Form, Input, Modal, Select, DatePicker, Icon } from 'antd';
import { EnvironmentTwoTone } from '@ant-design/icons';
const { TextArea } = Input;
import { connect } from 'react-redux';
import Uploads from '$components/Uploads';
@ -9,15 +10,50 @@ import moment from 'moment';
const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, firmList }) => {
const { projectRegime } = actions
const [showBaiduMap, setShowBaiduMap] = useState(true)
const [showBaiduMap, setShowBaiduMap] = useState(false)
const [form] = Form.useForm();
useEffect(() => {
// console.log(modelData);
if (modelData?.longitude && modelData?.latitude) {
form.setFieldValue('longitude', modelData?.longitude)
form.setFieldValue('latitude', modelData?.latitude)
}
var map = new AMap.Map('container', {
resizeEnable: true, //是否监控地图容器尺寸变化
zoom: 11, //初始化地图层级
center: [116.397428, 39.90923] //初始化地图中心点
});
var autoOptions = {
input: "tipinput"
};
AMap.plugin(['AMap.PlaceSearch', 'AMap.AutoComplete', 'AMap.Geocoder'], () => {
var auto = new AMap.AutoComplete(autoOptions);
var placeSearch = new AMap.PlaceSearch({
map: map
}); //构造地点查询类
function select (e) {
if (e) {
placeSearch.setCity(e.poi.adcode);
placeSearch.search(e.poi.name, function (status, result) {
form.setFieldValue('longitude', result.poiList.pois[0].location.lat)
form.setFieldValue('latitude', result.poiList.pois[0].location.lng)
}) //关键字查询查询
}
}
auto.on("select", select);//注册监听,当选中某条记录时会触发
map.on('click', function (e) { //点击地图获取经纬度
form.setFieldValue('longitude', e.lnglat.lat)
form.setFieldValue('latitude', e.lnglat.lng)
});
});
}, [])
return (
<Modal
title={modelData?.id ? '编辑项目' : '新建项目'}
@ -70,8 +106,8 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, f
{ value: '隧道', label: '隧道' },
{ value: '管廊', label: '管廊' }]} />
</Form.Item>
<div style={{}}>
<Form.Item label="所在地区:" labelCol={{ span: 11 }} labelAlign='right' name="longitude" initialValue={modelData?.longitude} style={{ display: 'inline-block', width: 'calc(60% - 30px)', }}
<div style={{ position: 'relative' }}>
<Form.Item label="所在地区:" labelCol={{ span: 11 }} labelAlign='right' name="longitude" style={{ display: 'inline-block', width: 'calc(60% - 30px)', }}
rules={[{ required: true, message: '', }, {
validator: (rule, value, callback) => {
const sjh = /^\d+$|^\d*\.\d+$/g;
@ -106,22 +142,25 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, f
>
<Input placeholder="维度支持数字" />
</Form.Item>
<EnvironmentTwoTone style={{ position: 'absolute', top: 5, right: 27, fontSize: 22 }} onClick={() => {
setShowBaiduMap(true)
}} />
</div>
{/* <Form.Item
<Form.Item
label={"地址"}
name='des'
name='location'
style={showBaiduMap ? { display: 'block' } : { display: 'none' }}
>
<Input id={"suggestId"} placeholder="输入地址,定位结构物位置" />
<Input id="tipinput" />
</Form.Item>
<Form.Item
label="地图"
name='dvdsv'
name='map'
style={showBaiduMap ? { display: 'block' } : { display: 'none' }}
>
<div id={"map"} style={{ width: '100%', height: '425px', marginBottom: '15px' }}></div>
</Form.Item> */}
<div id="container" style={{ width: '100%', height: '425px', marginBottom: '15px' }}></div>
</Form.Item>
<Form.Item name='describe' label="描述">
<TextArea />
</Form.Item>

27
web/log/development.txt

@ -5554,3 +5554,30 @@
'/_file-server/project/44501f2a-8fc5-4192-9669-efab29f2de23/5',
'jpg'
]
2023-01-30 17:12:58.649 - debug: [FS-LOGGER] Init.
2023-01-30 17:12:58.670 - debug: init fs.attachment and inject it into app(app.fs.attachment) and runtime ctx(ctx.fs.attachment)
2023-01-30 17:12:59.170 - info: [Router] Inject api: attachment/index
2023-01-30 17:16:13.327 - debug: [FS-LOGGER] Init.
2023-01-30 17:16:13.330 - debug: init fs.attachment and inject it into app(app.fs.attachment) and runtime ctx(ctx.fs.attachment)
2023-01-30 17:16:13.565 - info: [Router] Inject api: attachment/index
2023-01-30 17:18:13.216 - debug: [FS-LOGGER] Init.
2023-01-30 17:18:13.220 - debug: init fs.attachment and inject it into app(app.fs.attachment) and runtime ctx(ctx.fs.attachment)
2023-01-30 17:18:13.440 - info: [Router] Inject api: attachment/index
2023-01-30 17:22:40.363 - debug: [FS-LOGGER] Init.
2023-01-30 17:22:40.367 - debug: init fs.attachment and inject it into app(app.fs.attachment) and runtime ctx(ctx.fs.attachment)
2023-01-30 17:22:40.595 - info: [Router] Inject api: attachment/index
2023-01-30 17:26:24.834 - debug: [FS-LOGGER] Init.
2023-01-30 17:26:24.838 - debug: init fs.attachment and inject it into app(app.fs.attachment) and runtime ctx(ctx.fs.attachment)
2023-01-30 17:26:25.086 - info: [Router] Inject api: attachment/index
2023-01-30 17:31:02.807 - debug: [FS-LOGGER] Init.
2023-01-30 17:31:02.811 - debug: init fs.attachment and inject it into app(app.fs.attachment) and runtime ctx(ctx.fs.attachment)
2023-01-30 17:31:03.033 - info: [Router] Inject api: attachment/index
2023-01-30 17:36:21.492 - debug: [FS-LOGGER] Init.
2023-01-30 17:36:21.495 - debug: init fs.attachment and inject it into app(app.fs.attachment) and runtime ctx(ctx.fs.attachment)
2023-01-30 17:36:21.726 - info: [Router] Inject api: attachment/index
2023-01-30 17:40:58.100 - debug: [FS-LOGGER] Init.
2023-01-30 17:40:58.103 - debug: init fs.attachment and inject it into app(app.fs.attachment) and runtime ctx(ctx.fs.attachment)
2023-01-30 17:40:58.323 - info: [Router] Inject api: attachment/index
2023-01-31 08:39:58.707 - debug: [FS-LOGGER] Init.
2023-01-31 08:39:58.710 - debug: init fs.attachment and inject it into app(app.fs.attachment) and runtime ctx(ctx.fs.attachment)
2023-01-31 08:39:59.052 - info: [Router] Inject api: attachment/index

Loading…
Cancel
Save