@deepinnet-components/pc 0.0.46 → 0.0.48

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,2 +1,3 @@
1
+ import '../index.less';
1
2
  declare const Map: any;
2
3
  export default Map;
@@ -14,26 +14,22 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
14
14
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
16
  // @ts-nocheck
17
- import { useEffect, useState } from 'react';
18
- import imagesMap from '@/config/images';
19
- import { getBase64FromLocalImage } from '@/utils';
20
- import { getCityInfo } from '@/config/cityConfig';
17
+ import { useEffect, useRef, useState } from 'react';
18
+ import "../index.less";
21
19
  var Map = function Map(props) {
22
20
  var id = props.id,
23
21
  _props$opts = props.opts,
24
22
  opts = _props$opts === void 0 ? {} : _props$opts,
25
23
  children = props.children,
26
- _props$mapType = props.mapType,
27
- mapType = _props$mapType === void 0 ? 'default' : _props$mapType;
24
+ style = props.style,
25
+ className = props.className,
26
+ onData = props.onData;
28
27
  var _useState = useState(),
29
28
  _useState2 = _slicedToArray(_useState, 2),
30
29
  map = _useState2[0],
31
30
  setMap = _useState2[1];
31
+ var mapRef = useRef(null);
32
32
  function mapClick(e) {
33
- // 有值 说明点击的不是地图空的区域
34
- if (e.features) {
35
- return;
36
- }
37
33
  props.onClick(e);
38
34
  }
39
35
  function mapRightClick(e) {
@@ -41,63 +37,43 @@ var Map = function Map(props) {
41
37
  (_props$onRightClick = props.onRightClick) === null || _props$onRightClick === void 0 || _props$onRightClick.call(props, e);
42
38
  }
43
39
  var mapInit = function mapInit() {
44
- var cityInfo = getCityInfo();
45
- var isDev = cityInfo.indexFile === 'dev';
46
- if (isDev) {
47
- mapabcgl.setBaseApiUrl("".concat(location.origin, "/mapabcApi"));
40
+ if (mapabcgl) {
41
+ mapabcgl.accessToken = 'ec85d3648154874552835438ac6a02b2';
42
+ mapabcgl.config.accessToken = 'ec85d3648154874552835438ac6a02b2';
48
43
  }
49
44
  // 销毁现有的地图实例(如果有)
50
45
  if (map) {
51
46
  map.remove();
47
+ setMap(null);
52
48
  }
53
- var mapObj = new mapabcgl.Map(_objectSpread(_objectSpread({
49
+ var mapObj = new mapabcgl.Map(_objectSpread({
54
50
  container: id,
55
- style: cityInfo.mapStyle[mapType],
56
- center: cityInfo.center,
51
+ style: 'mapabc://style/mapabc79w',
52
+ center: [118.859358, 28.970404],
57
53
  zoom: 13,
58
54
  maxZoom: 26,
59
55
  minZoom: 3,
60
56
  dragRotate: false,
61
57
  doubleClickZoom: false
62
- }, opts), {}, {
63
- transformRequest: function transformRequest(url) {
64
- // 处理互联网地图跨域问题
65
- if (url.startsWith('http://121.36.99.212:35003') && isDev) {
66
- return {
67
- url: url.replace('http://121.36.99.212:35003', "".concat(location.origin, "/mapabcTileApi"))
68
- };
69
- }
70
- }
71
- }));
58
+ }, opts));
59
+ mapObj.dragRotate.disable();
72
60
  mapObj.getCanvas().style.cursor = 'default';
73
-
74
- // map加载完成后暴露出去使用
75
61
  mapObj.on('load', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
76
62
  return _regeneratorRuntime().wrap(function _callee$(_context) {
77
63
  while (1) switch (_context.prev = _context.next) {
78
64
  case 0:
79
65
  setMap(mapObj);
66
+ mapRef.current = mapObj;
80
67
  window.layerZIndexConfig = {};
81
- case 2:
68
+ case 3:
82
69
  case "end":
83
70
  return _context.stop();
84
71
  }
85
72
  }, _callee);
86
73
  })));
87
- mapObj.on('error', /*#__PURE__*/function () {
88
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(e) {
89
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
90
- while (1) switch (_context2.prev = _context2.next) {
91
- case 0:
92
- case "end":
93
- return _context2.stop();
94
- }
95
- }, _callee2);
96
- }));
97
- return function (_x) {
98
- return _ref2.apply(this, arguments);
99
- };
100
- }());
74
+ if (onData) {
75
+ mapObj === null || mapObj === void 0 || mapObj.on('data', onData);
76
+ }
101
77
  };
102
78
  useEffect(function () {
103
79
  mapInit();
@@ -112,81 +88,23 @@ var Map = function Map(props) {
112
88
  }, []);
113
89
  useEffect(function () {
114
90
  if (map) {
115
- props.setMap(map);
91
+ var _props$setMap;
92
+ (_props$setMap = props.setMap) === null || _props$setMap === void 0 || _props$setMap.call(props, map);
116
93
  if (props.onClick) {
117
94
  map === null || map === void 0 || map.on('click', mapClick);
118
95
  }
119
96
  if (props.onRightClick) {
120
97
  map === null || map === void 0 || map.on('contextmenu', mapRightClick);
121
98
  }
122
- if (import.meta.env.VITE_APP_STATUS === 'prod') {
123
- var cityInfo = getCityInfo();
124
- if (mapType === 'black') {
125
- map.addLayer({
126
- id: 'traffic-raster',
127
- type: 'raster',
128
- source: {
129
- type: 'raster',
130
- tiles: [cityInfo.mapStyle.blackTiles[0]],
131
- tileSize: 256
132
- }
133
- });
134
- map.addLayer({
135
- id: 'traffic-raster2',
136
- type: 'raster',
137
- source: {
138
- type: 'raster',
139
- tiles: [cityInfo.mapStyle.blackTiles[1]],
140
- tileSize: 256
141
- }
142
- });
143
- } else {
144
- map.addLayer({
145
- id: 'traffic-raster',
146
- type: 'raster',
147
- source: {
148
- type: 'raster',
149
- tiles: [cityInfo.mapStyle.defaultTiles[0]],
150
- tileSize: 256
151
- }
152
- });
153
- map.addLayer({
154
- id: 'traffic-raster2',
155
- type: 'raster',
156
- source: {
157
- type: 'raster',
158
- tiles: [cityInfo.mapStyle.defaultTiles[1]],
159
- tileSize: 256
160
- }
161
- });
162
- }
163
- }
164
- ;
165
- _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
166
- var base64, image;
167
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
168
- while (1) switch (_context3.prev = _context3.next) {
169
- case 0:
170
- _context3.next = 2;
171
- return getBase64FromLocalImage(imagesMap.arrow);
172
- case 2:
173
- base64 = _context3.sent;
174
- _context3.next = 5;
175
- return map.loadImage(base64);
176
- case 5:
177
- image = _context3.sent;
178
- map.addImage('custom-arrow', image.data);
179
- case 7:
180
- case "end":
181
- return _context3.stop();
182
- }
183
- }, _callee3);
184
- }))();
185
99
  }
186
100
  }, [map]);
187
101
  return /*#__PURE__*/React.createElement("div", {
188
102
  id: id,
189
- className: "w-[100%] h-[100%]"
103
+ className: "".concat(className),
104
+ style: _objectSpread({
105
+ width: '100%',
106
+ height: '100%'
107
+ }, style)
190
108
  }, !!map && children);
191
109
  };
192
110
  export default Map;
@@ -18,7 +18,7 @@ var MapMarker = function MapMarker(props) {
18
18
  _props$draggable = props.draggable,
19
19
  draggable = _props$draggable === void 0 ? false : _props$draggable,
20
20
  children = props.children;
21
- var _useState = useState('customMarker::' + shortid.generate()),
21
+ var _useState = useState('customMarker::' + (props.id || shortid.generate())),
22
22
  _useState2 = _slicedToArray(_useState, 1),
23
23
  id = _useState2[0];
24
24
  var somePropsRef = useRef();
@@ -18,7 +18,9 @@ var MapPolygon = function MapPolygon(props) {
18
18
  _props$opacity = props.opacity,
19
19
  opacity = _props$opacity === void 0 ? 1 : _props$opacity,
20
20
  _props$multi = props.multi,
21
- multi = _props$multi === void 0 ? false : _props$multi;
21
+ multi = _props$multi === void 0 ? false : _props$multi,
22
+ _props$isGetColor = props.isGetColor,
23
+ isGetColor = _props$isGetColor === void 0 ? false : _props$isGetColor;
22
24
  var _useState = useState('customPolygon::' + (props.id || shortid.generate())),
23
25
  _useState2 = _slicedToArray(_useState, 1),
24
26
  id = _useState2[0];
@@ -77,12 +79,16 @@ var MapPolygon = function MapPolygon(props) {
77
79
  setSourceData(sourceDataObj);
78
80
  }, [map, path]);
79
81
  function drawPolygon() {
82
+ var fillColor = color;
83
+ if (multi && isGetColor) {
84
+ fillColor = ['get', 'color'];
85
+ }
80
86
  var polygonObj = {
81
87
  id: id,
82
88
  type: 'fill',
83
89
  source: id,
84
90
  paint: {
85
- 'fill-color': color,
91
+ 'fill-color': fillColor,
86
92
  'fill-opacity': opacity
87
93
  }
88
94
  };
@@ -90,7 +96,7 @@ var MapPolygon = function MapPolygon(props) {
90
96
  var layer = map.getLayer(id);
91
97
  if (layer) {
92
98
  // console.log('更新layer');
93
- map.setPaintProperty(id, 'fill-color', color);
99
+ map.setPaintProperty(id, 'fill-color', fillColor);
94
100
  map.setPaintProperty(id, 'fill-opacity', opacity);
95
101
  } else {
96
102
  map.addLayer(polygonObj);
@@ -4,12 +4,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import { useEffect, useRef, useState, memo } from 'react';
8
7
  import { useGetState } from 'ahooks';
9
8
  import { isEqual } from 'lodash-es';
9
+ import { memo, useEffect, useRef, useState } from 'react';
10
10
  import shortid from 'shortid';
11
- import { getAllLineLayers } from "../utils";
12
- import { deepClone } from "../utils";
11
+ import { deepClone, getAllLineLayers } from "../utils";
13
12
  function findKeyWithMinValueGreaterThan(obj, a) {
14
13
  var ignoreKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
15
14
  var minValue = Infinity;
@@ -52,7 +51,9 @@ var MapPolyline = function MapPolyline(props) {
52
51
  _props$isArrow = props.isArrow,
53
52
  isArrow = _props$isArrow === void 0 ? false : _props$isArrow,
54
53
  _props$multi = props.multi,
55
- multi = _props$multi === void 0 ? false : _props$multi;
54
+ multi = _props$multi === void 0 ? false : _props$multi,
55
+ _props$isGetColor = props.isGetColor,
56
+ isGetColor = _props$isGetColor === void 0 ? false : _props$isGetColor;
56
57
  var _useState = useState('customLine::' + (props.id || shortid.generate())),
57
58
  _useState2 = _slicedToArray(_useState, 1),
58
59
  id = _useState2[0];
@@ -128,7 +129,7 @@ var MapPolyline = function MapPolyline(props) {
128
129
  useEffect(function () {
129
130
  if (map && line) {
130
131
  var lineColor = color;
131
- if (multi) {
132
+ if (multi && isGetColor) {
132
133
  lineColor = ['get', 'color'];
133
134
  }
134
135
  var lineObj = {
@@ -205,7 +206,7 @@ var MapPolyline = function MapPolyline(props) {
205
206
  zIndex: zIndex
206
207
  }
207
208
  };
208
- if (multi) {
209
+ if (multi && isGetColor) {
209
210
  lineObj.paint['line-color'] = ['get', 'color'];
210
211
  }
211
212
  if (lineEndColor) {
@@ -310,7 +311,7 @@ var MapPolyline = function MapPolyline(props) {
310
311
  });
311
312
  if (item && item.source === id) {
312
313
  var _props$onMouseenter;
313
- (_props$onMouseenter = props.onMouseenter) === null || _props$onMouseenter === void 0 || _props$onMouseenter.call(props, e);
314
+ (_props$onMouseenter = props.onMouseenter) === null || _props$onMouseenter === void 0 || _props$onMouseenter.call(props, features[0], e);
314
315
  }
315
316
  }
316
317
  function onMouseleave(e) {
@@ -327,7 +328,7 @@ var MapPolyline = function MapPolyline(props) {
327
328
  });
328
329
  if (item && item.source === id) {
329
330
  var _props$onClick;
330
- (_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, e);
331
+ (_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, features[0], e);
331
332
  }
332
333
  }
333
334
  function onRightClick(e) {
@@ -340,7 +341,7 @@ var MapPolyline = function MapPolyline(props) {
340
341
  });
341
342
  if (item && item.source === id) {
342
343
  var _props$onRightClick;
343
- (_props$onRightClick = props.onRightClick) === null || _props$onRightClick === void 0 || _props$onRightClick.call(props, e);
344
+ (_props$onRightClick = props.onRightClick) === null || _props$onRightClick === void 0 || _props$onRightClick.call(props, features[0], e);
344
345
  }
345
346
  }
346
347
 
@@ -54,7 +54,7 @@ function pointToSegmentDistance(p, p1, p2) {
54
54
  }
55
55
  var Index = /*#__PURE__*/forwardRef(function (props, ref) {
56
56
  var map = props.map,
57
- form = props.form;
57
+ onDataChange = props.onDataChange;
58
58
  var _useGetState = useGetState([]),
59
59
  _useGetState2 = _slicedToArray(_useGetState, 3),
60
60
  polygon = _useGetState2[0],
@@ -96,28 +96,29 @@ var Index = /*#__PURE__*/forwardRef(function (props, ref) {
96
96
  };
97
97
  });
98
98
  useEffect(function () {
99
- if (polygon.length >= 3) {
100
- form.setFieldState('wktPointsStr', function (state) {
101
- state.selfErrors = null;
102
- });
103
- var path = [].concat(_toConsumableArray(polygon), [polygon[0]]);
104
- var turfPolygon = turf.polygon([path]);
105
- var area = (turf.area(turfPolygon) / 1000000).toFixed(2);
106
- var wkt = wellknown.stringify({
107
- type: 'Polygon',
108
- coordinates: [path]
109
- });
110
- var match = wkt.match(/^POLYGON \(\((.+)\)\)$/);
111
- var wktPointsStr = match ? match[1] : '';
112
- form.setValues({
113
- area: area,
114
- wktPointsStr: wktPointsStr
115
- });
116
- } else {
117
- form.setValues({
118
- area: undefined,
119
- wktPointsStr: undefined
120
- });
99
+ if (onDataChange) {
100
+ if (polygon.length >= 3) {
101
+ var path = [].concat(_toConsumableArray(polygon), [polygon[0]]);
102
+ var turfPolygon = turf.polygon([path]);
103
+ var area = (turf.area(turfPolygon) / 1000000).toFixed(2);
104
+ var wkt = wellknown.stringify({
105
+ type: 'Polygon',
106
+ coordinates: [path]
107
+ });
108
+ var match = wkt.match(/^POLYGON \(\((.+)\)\)$/);
109
+ var wktPointsStr = match ? match[1] : '';
110
+ onDataChange({
111
+ area: area,
112
+ wktPointsStr: wktPointsStr,
113
+ wkt: wkt
114
+ });
115
+ } else {
116
+ onDataChange({
117
+ area: undefined,
118
+ wktPointsStr: undefined,
119
+ wkt: undefined
120
+ });
121
+ }
121
122
  }
122
123
  }, [polygon]);
123
124
  function _onMapClick(e) {
@@ -133,7 +134,7 @@ var Index = /*#__PURE__*/forwardRef(function (props, ref) {
133
134
  }, [polygon, polygonOk]);
134
135
 
135
136
  // 点击线添加节点
136
- var handleClickLine1 = function handleClickLine1(e) {
137
+ var handleClickLine = function handleClickLine(e) {
137
138
  setRightMenuShow(false);
138
139
  if (!_getPolygonOk()) return;
139
140
  var pos = [Number(e.lngLat.lng.toFixed(6)), Number(e.lngLat.lat.toFixed(6))];
@@ -255,8 +256,8 @@ var Index = /*#__PURE__*/forwardRef(function (props, ref) {
255
256
  path: mapLine,
256
257
  color: "rgba(0,0,0,0)",
257
258
  width: 10,
258
- onClick: function onClick(e) {
259
- handleClickLine1(e);
259
+ onClick: function onClick(current, e) {
260
+ handleClickLine(e);
260
261
  }
261
262
  }), rightMenuShow && /*#__PURE__*/React.createElement(MapMarker, {
262
263
  map: map,
@@ -9,14 +9,14 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
9
9
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
11
  // @ts-nocheck
12
- import React, { useState, useEffect, useImperativeHandle, forwardRef } from 'react';
13
- import { message } from 'antd';
14
12
  import * as turf from '@turf/turf';
15
13
  import { useGetState } from 'ahooks';
14
+ import { message } from 'antd';
15
+ import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
16
16
  import wellknown from 'wellknown';
17
17
  import MapMarker from "../MapMarker";
18
18
  import MapPolyline from "../MapPolyline";
19
- import { setFitView as _setFitView, deepClone } from "../utils";
19
+ import { deepClone, setFitView as _setFitView } from "../utils";
20
20
  import "../index.less";
21
21
 
22
22
  // 计算点到线段距离的辅助函数
@@ -53,11 +53,11 @@ function pointToSegmentDistance(p, p1, p2) {
53
53
  }
54
54
  var Index = /*#__PURE__*/forwardRef(function (props, ref) {
55
55
  var map = props.map,
56
- form = props.form;
56
+ onDataChange = props.onDataChange;
57
57
  var _useGetState = useGetState([]),
58
58
  _useGetState2 = _slicedToArray(_useGetState, 3),
59
59
  polygon = _useGetState2[0],
60
- _setPolygon = _useGetState2[1],
60
+ setPolygon = _useGetState2[1],
61
61
  getPolygon = _useGetState2[2]; // 代码copy的 先用这个 其实是polyline
62
62
 
63
63
  useImperativeHandle(ref, function () {
@@ -65,8 +65,8 @@ var Index = /*#__PURE__*/forwardRef(function (props, ref) {
65
65
  onMapClick: function onMapClick(e) {
66
66
  _onMapClick(e);
67
67
  },
68
- setPolygon: function setPolygon(params) {
69
- _setPolygon(params);
68
+ setPolyline: function setPolyline(params) {
69
+ setPolygon(params);
70
70
  },
71
71
  setFitView: function setFitView() {
72
72
  var timer = setInterval(function () {
@@ -84,29 +84,30 @@ var Index = /*#__PURE__*/forwardRef(function (props, ref) {
84
84
  };
85
85
  });
86
86
  useEffect(function () {
87
- if (polygon.length >= 2) {
88
- form.setFieldState('wktPointsStr', function (state) {
89
- state.selfErrors = null;
90
- });
91
- var path = _toConsumableArray(polygon);
92
- var length = turf.length(turf.lineString(path), {
93
- units: 'kilometers'
94
- }).toFixed(2);
95
- var wkt = wellknown.stringify({
96
- type: 'LineString',
97
- coordinates: path
98
- });
99
- var match = wkt.match(/^LINESTRING \((.+)\)$/);
100
- var wktPointsStr = match ? match[1] : '';
101
- form.setValues({
102
- length: length,
103
- wktPointsStr: wktPointsStr
104
- });
105
- } else {
106
- form.setValues({
107
- length: undefined,
108
- wktPointsStr: undefined
109
- });
87
+ if (onDataChange) {
88
+ if (polygon.length >= 2) {
89
+ var path = _toConsumableArray(polygon);
90
+ var length = turf.length(turf.lineString(path), {
91
+ units: 'kilometers'
92
+ });
93
+ var wkt = wellknown.stringify({
94
+ type: 'LineString',
95
+ coordinates: path
96
+ });
97
+ var match = wkt.match(/^LINESTRING \((.+)\)$/);
98
+ var wktPointsStr = match ? match[1] : '';
99
+ onDataChange({
100
+ length: length,
101
+ wktPointsStr: wktPointsStr,
102
+ wkt: wkt
103
+ });
104
+ } else {
105
+ onDataChange({
106
+ length: undefined,
107
+ wktPointsStr: undefined,
108
+ wkt: undefined
109
+ });
110
+ }
110
111
  }
111
112
  }, [polygon]);
112
113
  function _onMapClick(e) {
@@ -114,15 +115,14 @@ var Index = /*#__PURE__*/forwardRef(function (props, ref) {
114
115
  setRightMenuShow(false);
115
116
  var copy = deepClone(getPolygon());
116
117
  copy.push(pos);
117
- console.log(copy);
118
- _setPolygon(copy);
118
+ setPolygon(copy);
119
119
  }
120
120
  var onPointDragging = function onPointDragging(e, index) {
121
121
  setRightMenuShow(false);
122
122
  var pos = [Number(e.target._lngLat.lng.toFixed(6)), Number(e.target._lngLat.lat.toFixed(6))];
123
123
  var copy = deepClone(getPolygon());
124
124
  copy[index] = pos;
125
- _setPolygon(copy);
125
+ setPolygon(copy);
126
126
  };
127
127
 
128
128
  // 点击线添加节点
@@ -147,7 +147,7 @@ var Index = /*#__PURE__*/forwardRef(function (props, ref) {
147
147
  }
148
148
  var copy = deepClone(getPolygon());
149
149
  copy.splice(insertIndex, 0, pos);
150
- _setPolygon(copy);
150
+ setPolygon(copy);
151
151
  }
152
152
  var deleteMarker = function deleteMarker(rightMarkerIndex) {
153
153
  setRightMenuShow(false);
@@ -156,7 +156,7 @@ var Index = /*#__PURE__*/forwardRef(function (props, ref) {
156
156
  }
157
157
  var copy = deepClone(getPolygon());
158
158
  copy.splice(rightMarkerIndex, 1);
159
- _setPolygon(copy);
159
+ setPolygon(copy);
160
160
  };
161
161
 
162
162
  // 右键操作 begin
@@ -208,7 +208,7 @@ var Index = /*#__PURE__*/forwardRef(function (props, ref) {
208
208
  path: polygon,
209
209
  color: "#62ccff",
210
210
  width: 6,
211
- onClick: function onClick(e) {
211
+ onClick: function onClick(current, e) {
212
212
  handleClickLine(e);
213
213
  }
214
214
  }), rightMenuShow && /*#__PURE__*/React.createElement(MapMarker, {
@@ -2,6 +2,6 @@
2
2
  * title: 用法
3
3
  * description:
4
4
  */
5
- import type { FC } from 'react';
6
- declare const App: FC;
5
+ import React from 'react';
6
+ declare const App: () => React.JSX.Element;
7
7
  export default App;
@@ -1,14 +1,30 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
7
  /**
2
8
  * title: 用法
3
9
  * description:
4
10
  */
5
11
 
6
- import React from 'react';
7
- // import { Map2D } from '@deepinnet-components/pc'
8
-
9
- // const { Map, MapMarker, MapPolyline, MapPolygon } = Map2D
10
-
12
+ import { Map2D } from "../..";
13
+ import React, { useState } from 'react';
14
+ var Map = Map2D.Map;
11
15
  var App = function App() {
12
- return /*#__PURE__*/React.createElement("div", null, "\u8FD9\u4E2A\u6587\u6863\u4E0D\u597D\u641E\u4F8B\u5B50");
16
+ var _useState = useState(),
17
+ _useState2 = _slicedToArray(_useState, 2),
18
+ map = _useState2[0],
19
+ setMap = _useState2[1];
20
+ return /*#__PURE__*/React.createElement("div", {
21
+ style: {
22
+ width: '100%',
23
+ height: 500
24
+ }
25
+ }, /*#__PURE__*/React.createElement(Map, {
26
+ setMap: setMap,
27
+ id: "test-map1"
28
+ }));
13
29
  };
14
30
  export default App;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * title:
3
+ * description:
4
+ */
5
+ import React from 'react';
6
+ declare const App: () => React.JSX.Element;
7
+ export default App;
@@ -0,0 +1,61 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ /**
8
+ * title:
9
+ * description:
10
+ */
11
+
12
+ import { Map2D } from "../..";
13
+ import { Button } from 'antd';
14
+ import React, { useState } from 'react';
15
+ var Map = Map2D.Map,
16
+ MapMarker = Map2D.MapMarker;
17
+ var App = function App() {
18
+ var _useState = useState(),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ map = _useState2[0],
21
+ setMap = _useState2[1];
22
+ var _useState3 = useState([118.859358, 28.970404]),
23
+ _useState4 = _slicedToArray(_useState3, 2),
24
+ markerPosition = _useState4[0],
25
+ setMarkerPosition = _useState4[1];
26
+ var _useState5 = useState(false),
27
+ _useState6 = _slicedToArray(_useState5, 2),
28
+ show = _useState6[0],
29
+ setShow = _useState6[1]; // 这是测试代码
30
+
31
+ if (!show) {
32
+ return /*#__PURE__*/React.createElement(Button, {
33
+ onClick: function onClick() {
34
+ setShow(true);
35
+ }
36
+ }, "\u5C55\u793A\u6848\u4F8B");
37
+ }
38
+ return /*#__PURE__*/React.createElement("div", {
39
+ style: {
40
+ width: '100%',
41
+ height: 500
42
+ }
43
+ }, /*#__PURE__*/React.createElement(Map, {
44
+ setMap: setMap,
45
+ id: "test-map2",
46
+ onClick: function onClick(e) {
47
+ var pos = [e.lngLat.lng, e.lngLat.lat];
48
+ setMarkerPosition(pos);
49
+ }
50
+ }), !!map && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MapMarker, {
51
+ map: map,
52
+ position: markerPosition
53
+ }, /*#__PURE__*/React.createElement("div", {
54
+ style: {
55
+ width: 80,
56
+ height: 80,
57
+ background: '#f00'
58
+ }
59
+ }))));
60
+ };
61
+ export default App;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * title:
3
+ * description:
4
+ */
5
+ import React from 'react';
6
+ declare const App: () => React.JSX.Element;
7
+ export default App;
@@ -0,0 +1,76 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ /**
8
+ * title:
9
+ * description:
10
+ */
11
+
12
+ import { Map2D } from "../..";
13
+ import { Button } from 'antd';
14
+ import React, { useEffect, useState } from 'react';
15
+ // @ts-ignore
16
+ import img from "./imgs/plan-red.png";
17
+ var Map = Map2D.Map,
18
+ MapMarkerMulti = Map2D.MapMarkerMulti;
19
+ function generateRandomPoints(center, count, range) {
20
+ var _center = _slicedToArray(center, 2),
21
+ centerLng = _center[0],
22
+ centerLat = _center[1];
23
+ var points = [];
24
+ for (var i = 0; i < count; i++) {
25
+ var randomLng = centerLng + (Math.random() * 2 - 1) * range;
26
+ var randomLat = centerLat + (Math.random() * 2 - 1) * range;
27
+ points.push([randomLng, randomLat]);
28
+ }
29
+ return points;
30
+ }
31
+ var App = function App() {
32
+ var _useState = useState(),
33
+ _useState2 = _slicedToArray(_useState, 2),
34
+ map = _useState2[0],
35
+ setMap = _useState2[1];
36
+ var _useState3 = useState([]),
37
+ _useState4 = _slicedToArray(_useState3, 2),
38
+ list = _useState4[0],
39
+ setList = _useState4[1];
40
+ useEffect(function () {
41
+ var arr = generateRandomPoints([118.859358, 28.970404], 1000, 0.02);
42
+ setList(arr.map(function (item) {
43
+ return {
44
+ position: item
45
+ };
46
+ }));
47
+ }, []);
48
+ var _useState5 = useState(false),
49
+ _useState6 = _slicedToArray(_useState5, 2),
50
+ show = _useState6[0],
51
+ setShow = _useState6[1]; // 这是测试代码
52
+
53
+ if (!show) {
54
+ return /*#__PURE__*/React.createElement(Button, {
55
+ onClick: function onClick() {
56
+ setShow(true);
57
+ }
58
+ }, "\u5C55\u793A\u6848\u4F8B");
59
+ }
60
+ return /*#__PURE__*/React.createElement("div", {
61
+ style: {
62
+ width: '100%',
63
+ height: 500
64
+ }
65
+ }, /*#__PURE__*/React.createElement(Map, {
66
+ setMap: setMap,
67
+ id: "test-map3"
68
+ }), !!map && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MapMarkerMulti, {
69
+ map: map,
70
+ position: list,
71
+ multi: true,
72
+ img: img,
73
+ size: 1
74
+ })));
75
+ };
76
+ export default App;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * title:
3
+ * description:
4
+ */
5
+ import React from 'react';
6
+ declare const App: () => React.JSX.Element;
7
+ export default App;
@@ -0,0 +1,73 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ /**
8
+ * title:
9
+ * description:
10
+ */
11
+
12
+ import { Map2D } from "../..";
13
+ import { Button } from 'antd';
14
+ import React, { useState } from 'react';
15
+ var Map = Map2D.Map,
16
+ MapPolygon = Map2D.MapPolygon;
17
+ var App = function App() {
18
+ var _useState = useState(),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ map = _useState2[0],
21
+ setMap = _useState2[1];
22
+ var _useState3 = useState([[118.858358, 28.970404], [118.869358, 28.970404], [118.858358, 28.960404]]),
23
+ _useState4 = _slicedToArray(_useState3, 2),
24
+ path = _useState4[0],
25
+ setPath = _useState4[1];
26
+ var _useState5 = useState([{
27
+ position: [[118.876481, 28.98694], [118.883434, 28.979339], [118.890214, 28.979189]],
28
+ data: 1,
29
+ color: '#0ff'
30
+ }, {
31
+ position: [[118.877168, 28.972431], [118.883348, 28.960554], [118.892961, 28.970479]],
32
+ data: 2,
33
+ color: '#f0f'
34
+ }]),
35
+ _useState6 = _slicedToArray(_useState5, 2),
36
+ path2 = _useState6[0],
37
+ setPath2 = _useState6[1];
38
+ var _useState7 = useState(false),
39
+ _useState8 = _slicedToArray(_useState7, 2),
40
+ show = _useState8[0],
41
+ setShow = _useState8[1]; // 这是测试代码
42
+
43
+ if (!show) {
44
+ return /*#__PURE__*/React.createElement(Button, {
45
+ onClick: function onClick() {
46
+ setShow(true);
47
+ }
48
+ }, "\u5C55\u793A\u6848\u4F8B");
49
+ }
50
+ return /*#__PURE__*/React.createElement("div", {
51
+ style: {
52
+ width: '100%',
53
+ height: 500
54
+ }
55
+ }, /*#__PURE__*/React.createElement(Map, {
56
+ setMap: setMap,
57
+ id: "test-map5"
58
+ }), !!map && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MapPolygon, {
59
+ map: map,
60
+ path: path,
61
+ color: '#f00',
62
+ opacity: 0.5,
63
+ onClick: function onClick(e) {
64
+ console.log(e);
65
+ }
66
+ }), /*#__PURE__*/React.createElement(MapPolygon, {
67
+ map: map,
68
+ path: path2,
69
+ multi: true,
70
+ isGetColor: true
71
+ })));
72
+ };
73
+ export default App;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * title:
3
+ * description:
4
+ */
5
+ import React from 'react';
6
+ declare const App: () => React.JSX.Element;
7
+ export default App;
@@ -0,0 +1,75 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ /**
8
+ * title:
9
+ * description:
10
+ */
11
+
12
+ import { Map2D } from "../..";
13
+ import { Button, message } from 'antd';
14
+ import React, { useState } from 'react';
15
+ var Map = Map2D.Map,
16
+ MapPolyline = Map2D.MapPolyline;
17
+ var App = function App() {
18
+ var _useState = useState(),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ map = _useState2[0],
21
+ setMap = _useState2[1];
22
+ var _useState3 = useState([[118.858358, 28.970404], [118.869358, 28.970404], [118.858358, 28.960404]]),
23
+ _useState4 = _slicedToArray(_useState3, 2),
24
+ path = _useState4[0],
25
+ setPath = _useState4[1];
26
+ var _useState5 = useState([{
27
+ position: [[118.876481, 28.97994], [118.883434, 28.979339], [118.890214, 28.979189]],
28
+ data: 1,
29
+ color: '#0ff'
30
+ }, {
31
+ position: [[118.877168, 28.972431], [118.883348, 28.970554], [118.892961, 28.970479]],
32
+ data: 2,
33
+ color: '#f0f'
34
+ }]),
35
+ _useState6 = _slicedToArray(_useState5, 2),
36
+ path2 = _useState6[0],
37
+ setPath2 = _useState6[1];
38
+ var _useState7 = useState(false),
39
+ _useState8 = _slicedToArray(_useState7, 2),
40
+ show = _useState8[0],
41
+ setShow = _useState8[1]; // 这是测试代码
42
+
43
+ if (!show) {
44
+ return /*#__PURE__*/React.createElement(Button, {
45
+ onClick: function onClick() {
46
+ setShow(true);
47
+ }
48
+ }, "\u5C55\u793A\u6848\u4F8B");
49
+ }
50
+ return /*#__PURE__*/React.createElement("div", {
51
+ style: {
52
+ width: '100%',
53
+ height: 500
54
+ }
55
+ }, /*#__PURE__*/React.createElement(Map, {
56
+ setMap: setMap,
57
+ id: "test-map4"
58
+ }), !!map && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MapPolyline, {
59
+ map: map,
60
+ path: path,
61
+ color: '#f00',
62
+ onClick: function onClick(e) {
63
+ console.log(e);
64
+ }
65
+ }), /*#__PURE__*/React.createElement(MapPolyline, {
66
+ map: map,
67
+ path: path2,
68
+ multi: true,
69
+ onClick: function onClick(e) {
70
+ message.info(e.properties.data);
71
+ },
72
+ isGetColor: true
73
+ })));
74
+ };
75
+ export default App;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * title:
3
+ * description:
4
+ */
5
+ import React from 'react';
6
+ declare const App: () => React.JSX.Element;
7
+ export default App;
@@ -0,0 +1,105 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ /**
14
+ * title:
15
+ * description:
16
+ */
17
+
18
+ import { Map2D } from "../..";
19
+ import { Button, Input, message } from 'antd';
20
+ import React, { useRef, useState } from 'react';
21
+ import wellknown from 'wellknown';
22
+ var Map = Map2D.Map,
23
+ PolygonEdit = Map2D.PolygonEdit,
24
+ Utils = Map2D.Utils;
25
+ var isValidLngLat = Utils.isValidLngLat;
26
+ var App = function App() {
27
+ var _useState = useState(),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ map = _useState2[0],
30
+ setMap = _useState2[1];
31
+ var editRef = useRef();
32
+ var _useState3 = useState(),
33
+ _useState4 = _slicedToArray(_useState3, 2),
34
+ data = _useState4[0],
35
+ setData = _useState4[1];
36
+ function handleSetPolygon() {
37
+ var _wellknown$parse;
38
+ var wkt = data === null || data === void 0 ? void 0 : data.wkt;
39
+ // @ts-ignore
40
+ var path = (_wellknown$parse = wellknown.parse(wkt)) === null || _wellknown$parse === void 0 || (_wellknown$parse = _wellknown$parse.coordinates) === null || _wellknown$parse === void 0 ? void 0 : _wellknown$parse[0];
41
+ var flag = isValidLngLat(path);
42
+ if (flag && (path === null || path === void 0 ? void 0 : path.length) >= 3 && String(path[0]) === String(path[path.length - 1])) {
43
+ path.pop();
44
+ editRef.current.setPolygon(path);
45
+ editRef.current.setPolygonOk(true);
46
+ editRef.current.setFitView();
47
+ } else {
48
+ message.error('wkt有误');
49
+ }
50
+ }
51
+ var _useState5 = useState(false),
52
+ _useState6 = _slicedToArray(_useState5, 2),
53
+ show = _useState6[0],
54
+ setShow = _useState6[1]; // 这是测试代码
55
+
56
+ if (!show) {
57
+ return /*#__PURE__*/React.createElement(Button, {
58
+ onClick: function onClick() {
59
+ setShow(true);
60
+ }
61
+ }, "\u5C55\u793A\u6848\u4F8B");
62
+ }
63
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
64
+ style: {
65
+ width: '100%',
66
+ height: 500
67
+ }
68
+ }, /*#__PURE__*/React.createElement(Map, {
69
+ setMap: setMap,
70
+ id: "test-map7",
71
+ onClick: function onClick(e) {
72
+ var _editRef$current;
73
+ (_editRef$current = editRef.current) === null || _editRef$current === void 0 || _editRef$current.onMapClick(e);
74
+ }
75
+ }), !!map && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PolygonEdit, {
76
+ map: map,
77
+ ref: editRef,
78
+ onDataChange: function onDataChange(e) {
79
+ setData(e);
80
+ }
81
+ }))), /*#__PURE__*/React.createElement("div", {
82
+ style: {
83
+ marginTop: 10
84
+ }
85
+ }, "wkt\uFF1A"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Input.TextArea, {
86
+ value: data === null || data === void 0 ? void 0 : data.wkt,
87
+ rows: 6,
88
+ onChange: function onChange(e) {
89
+ setData(_objectSpread(_objectSpread({}, data), {}, {
90
+ wkt: e.target.value
91
+ }));
92
+ }
93
+ }), /*#__PURE__*/React.createElement(Button, {
94
+ type: "primary",
95
+ style: {
96
+ marginTop: 10
97
+ },
98
+ onClick: handleSetPolygon
99
+ }, "\u5C06wkt\u56DE\u663E\u5230\u5730\u56FE")), /*#__PURE__*/React.createElement("div", {
100
+ style: {
101
+ marginTop: 20
102
+ }
103
+ }, "\u9762\u79EF\uFF1A"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", null, data === null || data === void 0 ? void 0 : data.area, " km2")));
104
+ };
105
+ export default App;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * title:
3
+ * description:
4
+ */
5
+ import React from 'react';
6
+ declare const App: () => React.JSX.Element;
7
+ export default App;
@@ -0,0 +1,112 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ /**
14
+ * title:
15
+ * description:
16
+ */
17
+
18
+ import { Map2D } from "../..";
19
+ import { Button, Input, message } from 'antd';
20
+ import React, { useRef, useState } from 'react';
21
+ import wellknown from 'wellknown';
22
+ var Map = Map2D.Map,
23
+ PolylineEdit = Map2D.PolylineEdit,
24
+ Utils = Map2D.Utils;
25
+ var isValidLngLat = Utils.isValidLngLat,
26
+ setFitView = Utils.setFitView;
27
+ var App = function App() {
28
+ var _useState = useState(),
29
+ _useState2 = _slicedToArray(_useState, 2),
30
+ map = _useState2[0],
31
+ setMap = _useState2[1];
32
+ var editRef = useRef();
33
+ var _useState3 = useState(),
34
+ _useState4 = _slicedToArray(_useState3, 2),
35
+ data = _useState4[0],
36
+ setData = _useState4[1];
37
+ function handleSetPolyline() {
38
+ var _wellknown$parse;
39
+ var wkt = data === null || data === void 0 ? void 0 : data.wkt;
40
+ // @ts-ignore
41
+ var path = (_wellknown$parse = wellknown.parse(wkt)) === null || _wellknown$parse === void 0 ? void 0 : _wellknown$parse.coordinates;
42
+ var flag = isValidLngLat(path);
43
+ if (flag && (path === null || path === void 0 ? void 0 : path.length) >= 2) {
44
+ editRef.current.setPolyline(path);
45
+ // editRef.current.setFitView();
46
+ setTimeout(function () {
47
+ setFitView(map, {
48
+ top: 100,
49
+ right: 100,
50
+ bottom: 100,
51
+ left: 100
52
+ });
53
+ }, 200);
54
+ } else {
55
+ message.error('wkt有误');
56
+ }
57
+ }
58
+ var _useState5 = useState(false),
59
+ _useState6 = _slicedToArray(_useState5, 2),
60
+ show = _useState6[0],
61
+ setShow = _useState6[1]; // 这是测试代码
62
+
63
+ if (!show) {
64
+ return /*#__PURE__*/React.createElement(Button, {
65
+ onClick: function onClick() {
66
+ setShow(true);
67
+ }
68
+ }, "\u5C55\u793A\u6848\u4F8B");
69
+ }
70
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
71
+ style: {
72
+ width: '100%',
73
+ height: 500
74
+ }
75
+ }, /*#__PURE__*/React.createElement(Map, {
76
+ setMap: setMap,
77
+ id: "test-map6",
78
+ onClick: function onClick(e) {
79
+ var _editRef$current;
80
+ (_editRef$current = editRef.current) === null || _editRef$current === void 0 || _editRef$current.onMapClick(e);
81
+ }
82
+ }), !!map && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PolylineEdit, {
83
+ map: map,
84
+ ref: editRef,
85
+ onDataChange: function onDataChange(e) {
86
+ setData(e);
87
+ }
88
+ }))), /*#__PURE__*/React.createElement("div", {
89
+ style: {
90
+ marginTop: 10
91
+ }
92
+ }, "wkt\uFF1A"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Input.TextArea, {
93
+ value: data === null || data === void 0 ? void 0 : data.wkt,
94
+ rows: 6,
95
+ onChange: function onChange(e) {
96
+ setData(_objectSpread(_objectSpread({}, data), {}, {
97
+ wkt: e.target.value
98
+ }));
99
+ }
100
+ }), /*#__PURE__*/React.createElement(Button, {
101
+ type: "primary",
102
+ style: {
103
+ marginTop: 10
104
+ },
105
+ onClick: handleSetPolyline
106
+ }, "\u5C06wkt\u56DE\u663E\u5230\u5730\u56FE")), /*#__PURE__*/React.createElement("div", {
107
+ style: {
108
+ marginTop: 20
109
+ }
110
+ }, "\u7EBF\u957F\u5EA6\uFF1A"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", null, data === null || data === void 0 ? void 0 : data.length, " km")));
111
+ };
112
+ export default App;
@@ -1,10 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import * as Utils from './utils';
3
3
  declare const Map2D: {
4
+ Map: any;
4
5
  MapMarker: import("react").MemoExoticComponent<(props: any) => import("react").JSX.Element>;
5
- MapMarkerMulti: any;
6
6
  MapPolyline: any;
7
7
  MapPolygon: any;
8
+ MapMarkerMulti: any;
8
9
  PolygonEdit: import("react").FC<any>;
9
10
  PolylineEdit: import("react").FC<any>;
10
11
  Utils: typeof Utils;
@@ -1,4 +1,4 @@
1
- // import Map from './Map';
1
+ import Map from "./Map";
2
2
  import MapMarker from "./MapMarker";
3
3
  import MapMarkerMulti from "./MapMarkerMulti";
4
4
  import MapPolyline from "./MapPolyline";
@@ -7,11 +7,11 @@ import PolygonEdit from "./PolygonEdit";
7
7
  import PolylineEdit from "./PolylineEdit";
8
8
  import * as Utils from "./utils";
9
9
  var Map2D = {
10
- // Map,
10
+ Map: Map,
11
11
  MapMarker: MapMarker,
12
- MapMarkerMulti: MapMarkerMulti,
13
12
  MapPolyline: MapPolyline,
14
13
  MapPolygon: MapPolygon,
14
+ MapMarkerMulti: MapMarkerMulti,
15
15
  PolygonEdit: PolygonEdit,
16
16
  PolylineEdit: PolylineEdit,
17
17
  Utils: Utils
@@ -1,3 +1,6 @@
1
+ .mapabcgl-control-container {
2
+ display: none;
3
+ }
1
4
  .com-linePointMaker {
2
5
  width: 20px;
3
6
  height: 20px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepinnet-components/pc",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",