@hzab/form-render 1.3.2 → 1.4.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  const defaultVersion = "2.0";
2
- const defaultPlugins = ["AMap.Geocoder", "AMap.AutoComplete"];
2
+ const defaultPlugins = ["AMap.Geocoder", "AMap.AutoComplete", "AMap.PolygonEditor", "AMap.PolylineEditor"];
3
3
 
4
4
  if (!window._AMapLoaderTemp) {
5
5
  window._AMapLoaderTemp = {};
@@ -1,6 +1,8 @@
1
+ import * as turf from "@turf/turf";
2
+ import { nanoid } from "nanoid";
3
+
1
4
  import AMapLoader from "./loader";
2
5
  import { markerIconBase64 } from "../../../assets/svg-icon";
3
- import { nanoid } from "nanoid";
4
6
 
5
7
  if (!window._AMapLoaderTemp) {
6
8
  window._AMapLoaderTemp = {};
@@ -53,8 +55,15 @@ export class MapUtils {
53
55
  public pickerMarker;
54
56
  public markerIconConf;
55
57
  public markerConf;
58
+ public polyEditor = {
59
+ PolygonEditor: undefined,
60
+ PolylineEditor: undefined,
61
+ };
62
+ public polygonEnum;
63
+ public polygonConf;
64
+ public mapDomRef;
56
65
 
57
- constructor({ map, AMap, markerIconConf, markerConf }) {
66
+ constructor({ map, AMap, mapDomRef, markerIconConf, markerConf, polygonConf }) {
58
67
  if (!map) {
59
68
  throw new Error("请传入地图实例");
60
69
  }
@@ -62,6 +71,9 @@ export class MapUtils {
62
71
  this.AMap = AMap;
63
72
  this.markerIconConf = markerIconConf || {};
64
73
  this.markerConf = markerConf || {};
74
+ this.polygonEnum = {};
75
+ this.polygonConf = polygonConf || {};
76
+ this.mapDomRef = mapDomRef;
65
77
  }
66
78
 
67
79
  /**
@@ -127,6 +139,7 @@ export class MapUtils {
127
139
  console.warn("setMarker 请传入正确的经纬度");
128
140
  return;
129
141
  }
142
+
130
143
  const position = new AMap.LngLat(lon, lat);
131
144
  let _marker = marker || this.markers[id];
132
145
 
@@ -167,6 +180,114 @@ export class MapUtils {
167
180
  return _m;
168
181
  }
169
182
 
183
+ /**
184
+ * 创建绘制实例
185
+ */
186
+ createPoly(element) {
187
+ if (element !== "Polypoint") {
188
+ // 同时绘制多种形状问题修复
189
+ if (this.polyEditor[`${element}Editor`]) {
190
+ return this.polyEditor[`${element}Editor`];
191
+ }
192
+ this.polyEditor[`${element}Editor`] = new this.AMap[`${element}Editor`](this.map, undefined, {
193
+ createOptions: {
194
+ strokeColor: "#1791fc",
195
+ strokeWeight: 2,
196
+ fillOpacity: 0.4,
197
+ fillColor: "#1791fc",
198
+ },
199
+ editOptions: {
200
+ strokeColor: "#1791fc",
201
+ strokeWeight: 2,
202
+ fillOpacity: 0.4,
203
+ fillColor: "#1791fc",
204
+ },
205
+ ...this.polygonConf,
206
+ });
207
+ }
208
+ }
209
+
210
+ /**
211
+ * 按points绘制元素实例
212
+ */
213
+ setPolygon(opt) {
214
+ const { points, id, onClick, element = "Polygon", map = this.map, AMap = this.AMap } = opt;
215
+
216
+ if (!(AMap && map)) {
217
+ throw new Error("请传入地图实例和 AMap");
218
+ }
219
+
220
+ const marker = this.polygonEnum[id];
221
+ if (marker) {
222
+ return;
223
+ }
224
+
225
+ const graphical = new this.AMap[element]({
226
+ path: points,
227
+ strokeColor: "#1791fc",
228
+ strokeWeight: 2,
229
+ fillOpacity: 0.4,
230
+ fillColor: "#1791fc",
231
+ });
232
+
233
+ graphical.id = id;
234
+ // 多边形绘制完毕保存中心点
235
+ graphical.path = points;
236
+ graphical.center = this.getPolygonCenter(points);
237
+ this.polygonEnum[id] = graphical;
238
+ this.map.add([graphical]);
239
+ graphical.on("click", onClick);
240
+ }
241
+
242
+ /**
243
+ * 创建手动绘制实例
244
+ */
245
+ startPolygon(opt) {
246
+ const { onClick, element = "Polygon" } = opt;
247
+ this.polyEditor[`${element}Editor`].on("add", (data) => {
248
+ const id = nanoid();
249
+ data.target.id = id;
250
+ const graphical = data.target;
251
+ this.polygonEnum[id] = graphical;
252
+ graphical.on("click", onClick);
253
+ });
254
+
255
+ this.polyEditor[`${element}Editor`].on("end", (data) => {
256
+ // 多边形绘制完毕保存中心点
257
+ const graphical = data.target;
258
+ if (graphical.type === "AMap.Overlay") {
259
+ graphical.path = graphical.getPath().map((item) => [item.lng, item.lat]);
260
+ graphical.center = this.getPolygonCenter(graphical.path);
261
+ }
262
+ });
263
+ }
264
+
265
+ /**
266
+ * 手动开始绘制函数
267
+ */
268
+ setDrawPolygon({ map = this.map, AMap = this.AMap, element = "Polygon" }) {
269
+ if (!(AMap && map)) {
270
+ throw new Error("请传入地图实例和 AMap");
271
+ }
272
+ this.polyEditor[`${element}Editor`].close();
273
+ this.polyEditor[`${element}Editor`].setTarget();
274
+ this.polyEditor[`${element}Editor`].open();
275
+ }
276
+
277
+ /**
278
+ * 编辑态
279
+ * @param item
280
+ */
281
+ setEditPolygon({ id, element = "Polygon" }) {
282
+ const target = this.polygonEnum[id];
283
+ if (!target) {
284
+ console.warn("setEditPolygon 找不到目标对象:", id);
285
+ return;
286
+ }
287
+ this.polyEditor[`${element}Editor`].setTarget(target);
288
+ this.polyEditor[`${element}Editor`].open();
289
+ }
290
+
170
291
  setMarkerIcon(
171
292
  id,
172
293
  opt = {
@@ -194,6 +315,13 @@ export class MapUtils {
194
315
  marker.setOffset(new AMap.Pixel(...offset));
195
316
  }
196
317
 
318
+ rmPolygon(id, element = "Polygon") {
319
+ this.map.remove(this.polygonEnum[id]);
320
+ this.polyEditor[`${element}Editor`].close();
321
+ this.polyEditor[`${element}Editor`].setTarget();
322
+ delete this.polygonEnum[id];
323
+ }
324
+
197
325
  /**
198
326
  * 删除指定 marker
199
327
  * @param id
@@ -256,11 +384,22 @@ export class MapUtils {
256
384
  * @returns
257
385
  */
258
386
  setPickerMarker(lon, lat, opt?: any) {
259
- const { marker = this.pickerMarker } = opt || {};
260
- this.pickerMarker = this.setMarker(lon, lat, {
261
- ...opt,
262
- marker,
263
- });
387
+ if (lon && lat) {
388
+ const { marker = this.pickerMarker } = opt || {};
389
+ this.pickerMarker = this.setMarker(lon, lat, {
390
+ ...opt,
391
+ marker,
392
+ });
393
+ }
394
+ }
395
+
396
+ getPolygonCenter(coordinate) {
397
+ if (coordinate.length > 0) {
398
+ let features = turf.featureCollection(coordinate.map((item) => turf.point(item)));
399
+ let center = turf.center(features).geometry.coordinates;
400
+ return center;
401
+ }
402
+ return [];
264
403
  }
265
404
 
266
405
  on(...args) {
@@ -27,12 +27,13 @@ function AMapCom(props) {
27
27
  mapRef.current = new AMap.Map(mapDomRef.current, {
28
28
  zoom: zoom || 14,
29
29
  center: center || [120.160217, 30.243861],
30
+ doubleClickZoom: false,
30
31
  });
31
32
  init &&
32
33
  init({
33
34
  mapDomRef,
34
35
  map: mapRef.current,
35
- mapUtils: new MapUtils({ map: mapRef.current, AMap, markerIconConf }),
36
+ mapUtils: new MapUtils({ map: mapRef.current, AMap, markerIconConf, mapDomRef }),
36
37
  AMap,
37
38
  });
38
39
  });
@@ -22,6 +22,7 @@ export default function AMap(props) {
22
22
  | 参数 | 类型 | 必填 | 默认值 | 说明 |
23
23
  | ------------------ | ------- | ---- | --------- | ------------------------------------------------ |
24
24
  | mode | string | 否 | dialog | 地图显示的类型, dialog 弹窗显示、 show 直接显示 |
25
+ | element | string | 否 | Polypoint | 地图绘制的元素名Polypoint&Polyline&Polygon |
25
26
  | layout | string | 否 | ver | 选择器和地图的布局 hor 水平、 ver 垂直 |
26
27
  | hasSearch | boolean | 否 | true | 是否允许搜索 |
27
28
  | isAutoFixAddr | boolean | 否 | false | 打开地图时是否根据经纬度自动修正已填的地址 |
@@ -11,15 +11,18 @@
11
11
  }
12
12
  */
13
13
  export function getPropsValue(value = {}, opt) {
14
- const { lonKey = "longitude", latKey = "latitude", addrKey = "address" } = opt || {};
14
+ const { lonKey = "longitude", latKey = "latitude", addrKey = "address", pointsKey = "points" } = opt || {};
15
+
15
16
  let lon = value[lonKey];
16
17
  let lat = value[latKey];
17
18
  let addr = value[addrKey];
18
- // 数据和其他子项平级的情况
19
+ let points = value[pointsKey];
20
+
19
21
  const res = {
20
22
  lon,
21
23
  lat,
22
24
  addr,
25
+ points
23
26
  };
24
27
  return res;
25
28
  }
@@ -19,6 +19,7 @@ import "./index.less";
19
19
  export const ModalContent = observer((props: any) => {
20
20
  const {
21
21
  mode,
22
+ element = "Polypoint",
22
23
  /**
23
24
  * 选择器和地图的布局
24
25
  * 水平 输入框在前 hor
@@ -36,6 +37,7 @@ export const ModalContent = observer((props: any) => {
36
37
  lonKey = "longitude",
37
38
  latKey = "latitude",
38
39
  addrKey = "address",
40
+ pointsKey = "points",
39
41
  value,
40
42
  // 搜索框是否自动搜索
41
43
  isAutoSearch = true,
@@ -48,6 +50,7 @@ export const ModalContent = observer((props: any) => {
48
50
  icons,
49
51
  markerIconConf,
50
52
  getCurPositionConf,
53
+ init,
51
54
  } = props;
52
55
 
53
56
  const mapUtilsRef = useRef<MapUtils>();
@@ -59,8 +62,9 @@ export const ModalContent = observer((props: any) => {
59
62
  lonKey,
60
63
  latKey,
61
64
  addrKey,
65
+ pointsKey,
62
66
  }),
63
- [lonKey, latKey, addrKey, value, value?.[lonKey], value?.[latKey], value?.[addrKey]],
67
+ [lonKey, latKey, addrKey, pointsKey, value, value?.[pointsKey], value?.[lonKey], value?.[latKey], value?.[addrKey]],
64
68
  );
65
69
 
66
70
  const [loading, setLoading] = useState(props.loading || false);
@@ -81,6 +85,7 @@ export const ModalContent = observer((props: any) => {
81
85
  // mode === 'show' 的情况
82
86
  let _lon = formatVal.lon;
83
87
  let _lat = formatVal.lat;
88
+ let _points = formatVal.points;
84
89
  formatValRef.current = {
85
90
  ...formatVal,
86
91
  };
@@ -88,12 +93,20 @@ export const ModalContent = observer((props: any) => {
88
93
  // 解决关闭弹窗之后点位不居中的问题
89
94
  if (window.AMap && window.AMap.LngLat) {
90
95
  setMapCenter(_lon, _lat);
91
- setPickPoint(_lon, _lat, { isAutoFixAddr: false, addr: formatVal.addr });
96
+ if (element === "Polypoint") {
97
+ setPickPoint(_lon, _lat, { isAutoFixAddr: false, addr: formatVal.addr });
98
+ } else {
99
+ setDrawEditor(_points || []);
100
+ }
92
101
  } else {
93
102
  // 解决刷新页面 AMap 未加载导致的异常问题
94
103
  window._AMapLoaderTemp?.promise?.then(() => {
95
104
  setMapCenter(_lon, _lat);
96
- setPickPoint(_lon, _lat, { isAutoFixAddr: false, addr: formatVal.addr });
105
+ if (element === "Polypoint") {
106
+ setPickPoint(_lon, _lat, { isAutoFixAddr: false, addr: formatVal.addr });
107
+ } else {
108
+ setDrawEditor(_points || []);
109
+ }
97
110
  });
98
111
  }
99
112
  }
@@ -101,6 +114,7 @@ export const ModalContent = observer((props: any) => {
101
114
  // 处理弹窗展示数据回显逻辑
102
115
  let _lon = defaultLocation.lon;
103
116
  let _lat = defaultLocation.lat;
117
+ let _points = defaultLocation.points || [];
104
118
  let addr = defaultLocation.addr;
105
119
  if (formatVal.lon && formatVal.lat) {
106
120
  _lon = formatVal.lon;
@@ -117,40 +131,119 @@ export const ModalContent = observer((props: any) => {
117
131
  });
118
132
  }
119
133
  if (_lon && _lat && _lon !== pickerInfoRef.current?.lon && _lat !== pickerInfoRef.current?.lat) {
120
- setPickPoint(_lon, _lat, { isAutoFixAddr: false, addr: addr });
134
+ if (element === "Polypoint") {
135
+ setPickPoint(_lon, _lat, { isAutoFixAddr: false, addr: addr });
136
+ } else {
137
+ setDrawEditor(_points || []);
138
+ }
139
+ }
140
+ }
141
+ init({ editDone: onMapDbClick });
142
+ return () => {
143
+ // 取消监听
144
+ mapUtilsRef.current?.off("dblclick", onMapDbClick);
145
+ mapUtilsRef.current?.off("click", onClickMap);
146
+ };
147
+ }, []);
148
+
149
+ async function onMapDbClick() {
150
+ if (element !== "Polypoint") {
151
+ const graphical = mapUtilsRef.current.polyEditor[`${element}Editor`].getTarget();
152
+ if (graphical) {
153
+ const points = graphical.getPath().map((item) => [item.lng, item.lat]);
154
+ const center = mapUtilsRef.current.getPolygonCenter(points);
155
+ const addr = await getAddr(center[0], center[1]);
156
+ mapUtilsRef.current.polyEditor[`${element}Editor`].close();
157
+ mapUtilsRef.current.polyEditor[`${element}Editor`].setTarget();
158
+ props.setPickInfo &&
159
+ props.setPickInfo({
160
+ points,
161
+ addr,
162
+ lon: center[0],
163
+ lat: center[1],
164
+ });
165
+ setPickInfo({
166
+ points,
167
+ addr,
168
+ lon: center[0],
169
+ lat: center[1],
170
+ });
121
171
  }
122
172
  }
123
- }, [visibleKey, formatVal, isShowMode]);
173
+ }
124
174
 
125
175
  function mapInit({ map, mapUtils }) {
126
176
  mapUtilsRef.current = mapUtils;
177
+ mapUtilsRef.current.on("dblclick", onMapDbClick);
127
178
  let _lon = defaultLocation.lon;
128
179
  let _lat = defaultLocation.lat;
180
+ let _points = defaultLocation.points;
129
181
  if (pickInfo.lon && pickInfo.lat) {
130
182
  _lon = pickInfo.lon;
131
183
  _lat = pickInfo.lat;
184
+ _points = pickInfo.points;
132
185
  } else if (formatValRef.current?.lon && formatValRef.current?.lat) {
133
186
  _lon = formatValRef.current?.lon;
134
187
  _lat = formatValRef.current?.lat;
188
+ _points = formatValRef.current?.points;
135
189
  }
136
190
 
137
191
  setMapCenter(_lon, _lat);
138
192
 
139
193
  setLoading(props.loading || false);
140
-
141
194
  if (!(disabled || readOnly)) {
142
- mapUtilsRef.current?.setPickerMarker(_lon, _lat);
143
- // 点击选中点位的情况
144
- mapUtilsRef.current.on("click", function (ev) {
145
- const { lng: evLon, lat: evLat } = ev.lnglat || {};
146
- setPickPoint(evLon, evLat, { changeCenter: true });
147
- });
195
+ if (element === "Polypoint") {
196
+ mapUtilsRef.current?.setPickerMarker(_lon, _lat);
197
+ // 点击选中点位的情况
198
+ mapUtilsRef.current.on("click", onClickMap);
199
+ } else {
200
+ mapUtilsRef.current?.createPoly(element);
201
+ if (_points.length == 0) {
202
+ mapUtilsRef.current?.startPolygon({
203
+ onClick: onPolygonClick,
204
+ element,
205
+ });
206
+ mapUtilsRef.current.setDrawPolygon({ element });
207
+ }
208
+ setDrawEditor(_points);
209
+ }
148
210
  } else {
149
211
  // 禁用、只读情况使用 marker 展示点位
150
- mapUtilsRef.current?.setPickerMarker(_lon, _lat);
212
+ if (element === "Polypoint") {
213
+ mapUtilsRef.current?.setPickerMarker(_lon, _lat);
214
+ } else {
215
+ setDrawEditor(_points, true);
216
+ }
151
217
  }
152
218
  }
153
219
 
220
+ function onClickMap(ev) {
221
+ const { lng: evLon, lat: evLat } = ev.lnglat || {};
222
+ if (element === "Polypoint") {
223
+ console.log(evLon, evLat);
224
+ setPickPoint(evLon, evLat, { changeCenter: true });
225
+ }
226
+ }
227
+
228
+ function setDrawEditor(_points, disabled = false) {
229
+ if (!mapUtilsRef.current) {
230
+ return;
231
+ }
232
+ mapUtilsRef.current?.createPoly(element);
233
+ if (_points && _points.length > 0) {
234
+ const graphical = mapUtilsRef.current?.setPolygon({
235
+ points: _points,
236
+ id: "setDrawEditor",
237
+ element,
238
+ onClick: !disabled && onPolygonClick,
239
+ });
240
+ }
241
+ }
242
+
243
+ function onPolygonClick(e) {
244
+ mapUtilsRef.current.setEditPolygon({ ...e.target, element });
245
+ }
246
+
154
247
  /**
155
248
  * 设置地图中心点
156
249
  * @param lon
@@ -228,33 +321,27 @@ export const ModalContent = observer((props: any) => {
228
321
  // 展示获取当前定位按钮 props.showGetPositionBtn !== false 且非禁用、只读模式
229
322
  const showGetPositionBtn = props.showGetPositionBtn !== false && !(disabled || readOnly);
230
323
 
231
- const pickInfoRender = function () {
232
- /* 点击/移动 地图选中的数据 */
233
- return (
324
+ const { markerIcon, positionIcon, resetIcon } = icons || {};
325
+
326
+ return (
327
+ <div className={`location-picker-modal-content location-mode-${mode} location-modal-content-layout-${layout}`}>
234
328
  <PickerInfo
329
+ element={element}
235
330
  pickInfo={pickInfo}
236
331
  setPickInfo={setPickInfo}
237
332
  setPoint={setPickPoint}
238
333
  addrLoading={addrLoading}
239
334
  defaultLocation={defaultLocation}
240
335
  disabled={disabled}
241
- readOnly={readOnly}
336
+ readOnly={element !== "Polypoint" ? true : readOnly}
242
337
  />
243
- );
244
- };
245
-
246
- const { markerIcon, positionIcon, resetIcon } = icons || {};
247
-
248
- return (
249
- <div className={`location-picker-modal-content location-mode-${mode} location-modal-content-layout-${layout}`}>
250
- {pickInfoRender()}
251
338
  <div className="location-picker-map-wrap">
252
339
  <div className="location-picker-map">
253
340
  {/* 关闭弹窗之后清除搜索内容 */}
254
- {hasSearch ? (
341
+ {hasSearch && !disabled && !readOnly ? (
255
342
  <MapSearch
256
343
  key={visible}
257
- setPoint={readOnly || disabled ? setMapCenter : setPickPoint}
344
+ setPoint={element !== "Polypoint" && (readOnly || disabled) ? setMapCenter : setPickPoint}
258
345
  isAutoSearch={isAutoSearch}
259
346
  />
260
347
  ) : null}
@@ -269,7 +356,7 @@ export const ModalContent = observer((props: any) => {
269
356
  )}
270
357
  </div>
271
358
  {/* 获取当前经纬度 */}
272
- {showGetPositionBtn ? (
359
+ {showGetPositionBtn && element === "Polypoint" ? (
273
360
  <div className="actions-icon-box center-icon-box" onClick={getPosition}>
274
361
  {typeof positionIcon === "string" ? (
275
362
  <img className="center-icon" src={positionIcon} />
@@ -3,7 +3,16 @@ import { InputNumber, Spin } from "antd";
3
3
  import "./index.less";
4
4
 
5
5
  export const PickerInfo = (props) => {
6
- const { pickInfo, setPickInfo, setPoint, addrLoading, defaultLocation, disabled, readOnly } = props;
6
+ const { element, pickInfo, setPickInfo, setPoint, addrLoading, defaultLocation, disabled, readOnly } = props;
7
+
8
+ if (element === "Polyline") {
9
+ const handlePoints = (points) => {
10
+ if (points && points.length > 0) {
11
+ return points.join(", ");
12
+ }
13
+ };
14
+ return <div>经纬度:[ {handlePoints(pickInfo.points)} ]</div>;
15
+ }
7
16
 
8
17
  function onPILonChange(e) {
9
18
  const val = e?.target?.value ?? e;
@@ -1,8 +1,12 @@
1
1
  .location-value-box {
2
2
  .location-value-head-box {
3
3
  display: flex;
4
+
4
5
  .location-lon-lat {
5
6
  flex: 1;
7
+ white-space: nowrap;
8
+ overflow: hidden;
9
+ text-overflow: ellipsis;
6
10
  }
7
11
  }
8
12
 
@@ -10,12 +14,15 @@
10
14
  padding: 4px 0;
11
15
  padding-left: 5px;
12
16
  line-height: 1;
17
+
13
18
  &:focus {
14
19
  background: transparent;
15
20
  }
21
+
16
22
  .location-picker-icon-box {
17
23
  display: inline-block;
18
24
  margin-right: 4px;
25
+
19
26
  svg,
20
27
  img {
21
28
  width: 16px;
@@ -23,9 +30,10 @@
23
30
  vertical-align: middle;
24
31
  }
25
32
  }
33
+
26
34
  .location-picker-text {
27
35
  display: inline-block;
28
36
  vertical-align: middle;
29
37
  }
30
38
  }
31
- }
39
+ }
@@ -1,5 +1,5 @@
1
1
  import { useMemo } from "react";
2
- import { Button } from "antd";
2
+ import { Button, Divider } from "antd";
3
3
  import { observer } from "@formily/react";
4
4
 
5
5
  import { pickerIcon as pickerIconDefault } from "../../assets/svg-icon";
@@ -13,7 +13,7 @@ import "./index.less";
13
13
  * @returns
14
14
  */
15
15
  export const ResInfo = observer((props: any) => {
16
- const { onShow, lonKey, latKey, addrKey, value, pickerText = "选点", pickerIcon } = props || {};
16
+ const { onShow, lonKey, latKey, addrKey, pointsKey, value, pickerIcon, element } = props || {};
17
17
 
18
18
  // 数据格式转为内部格式,方便存取
19
19
  const formatVal = useMemo(
@@ -22,16 +22,30 @@ export const ResInfo = observer((props: any) => {
22
22
  lonKey,
23
23
  latKey,
24
24
  addrKey,
25
+ pointsKey,
25
26
  }),
26
- [lonKey, latKey, addrKey, value, value?.[lonKey], value?.[latKey], value?.[addrKey]],
27
+ [lonKey, latKey, addrKey, value, pointsKey, value?.[pointsKey], value?.[lonKey], value?.[latKey], value?.[addrKey]],
27
28
  );
28
29
 
30
+ const handlePoints = (points) => {
31
+ if (points && points.length > 0) {
32
+ return points.join(", ");
33
+ }
34
+ };
35
+
29
36
  return (
30
37
  <div className="location-value-box">
31
38
  <div className="location-value-head-box">
32
39
  <div className="location-lon-lat">
33
- <div>经度:{formatVal.lon} </div>
34
- <div>纬度:{formatVal.lat}</div>
40
+ {element === "Polyline" ? (
41
+ <div>经纬度:[ {handlePoints(formatVal.points)} ]</div>
42
+ ) : (
43
+ <div>
44
+ <div>经度:{formatVal.lon} </div>
45
+ <div>纬度:{formatVal.lat}</div>
46
+ <div>地址:{formatVal.addr}</div>
47
+ </div>
48
+ )}
35
49
  </div>
36
50
  <Button className="location-btn" color="primary" type="text" onClick={onShow}>
37
51
  <span className="location-picker-icon-box">
@@ -41,10 +55,9 @@ export const ResInfo = observer((props: any) => {
41
55
  pickerIcon || pickerIconDefault
42
56
  )}
43
57
  </span>
44
- <span className="location-picker-text">{pickerText}</span>
58
+ <span className="location-picker-text">{element === "Polypoint" ? "选点" : "绘制"}</span>
45
59
  </Button>
46
60
  </div>
47
- <div>地址:{formatVal.addr}</div>
48
61
  </div>
49
62
  );
50
63
  });