@deepinnet-components/pc 0.0.43 → 0.0.44

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.
@@ -4,18 +4,21 @@ 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
+ // @ts-nocheck
7
8
  import { useEffect, useState, memo } from 'react';
8
9
  import { useGetState } from 'ahooks';
9
10
  import { isEqual } from 'lodash-es';
10
11
  import shortid from 'shortid';
11
12
  var MapPolygon = function MapPolygon(props) {
12
13
  var map = props.map,
13
- _props$position = props.position,
14
- position = _props$position === void 0 ? [] : _props$position,
14
+ _props$path = props.path,
15
+ path = _props$path === void 0 ? [] : _props$path,
15
16
  _props$color = props.color,
16
17
  color = _props$color === void 0 ? '#1890ff' : _props$color,
17
18
  _props$opacity = props.opacity,
18
- opacity = _props$opacity === void 0 ? 1 : _props$opacity;
19
+ opacity = _props$opacity === void 0 ? 1 : _props$opacity,
20
+ _props$multi = props.multi,
21
+ multi = _props$multi === void 0 ? false : _props$multi;
19
22
  var _useState = useState('customPolygon::' + (props.id || shortid.generate())),
20
23
  _useState2 = _slicedToArray(_useState, 1),
21
24
  id = _useState2[0];
@@ -31,40 +34,48 @@ var MapPolygon = function MapPolygon(props) {
31
34
  getPolygon = _useGetState4[2];
32
35
  useEffect(function () {
33
36
  if (!map) return;
34
- var sourceDataObj = {
35
- type: 'FeatureCollection',
36
- features: [{
37
- type: 'Feature',
38
- geometry: {
39
- type: 'Polygon',
40
- coordinates: [position]
41
- }
42
- }]
43
- };
37
+ var sourceDataObj;
38
+ if (multi) {
39
+ var features = [];
40
+ path.forEach(function (item) {
41
+ features.push({
42
+ type: 'Feature',
43
+ properties: item,
44
+ geometry: {
45
+ type: 'Polygon',
46
+ coordinates: [item.position]
47
+ }
48
+ });
49
+ });
50
+ sourceDataObj = {
51
+ type: 'FeatureCollection',
52
+ features: features
53
+ };
54
+ } else {
55
+ sourceDataObj = {
56
+ type: 'FeatureCollection',
57
+ features: [{
58
+ type: 'Feature',
59
+ geometry: {
60
+ type: 'Polygon',
61
+ coordinates: [path]
62
+ }
63
+ }]
64
+ };
65
+ }
44
66
  if (isEqual(getSourceData(), sourceDataObj)) return;
45
- sourceDataObj = {
46
- type: 'FeatureCollection',
47
- features: [{
48
- type: 'Feature',
49
- geometry: {
50
- type: 'Polygon',
51
- coordinates: [position]
52
- }
53
- }]
54
- };
55
67
  var source = map.getSource(id);
56
68
  if (source) {
57
69
  // console.log('更新source');
58
70
  source.setData(sourceDataObj);
59
71
  } else {
60
- // console.log('添加source');
61
72
  map.addSource(id, {
62
73
  type: 'geojson',
63
74
  data: sourceDataObj
64
75
  });
65
76
  }
66
77
  setSourceData(sourceDataObj);
67
- }, [map, position]);
78
+ }, [map, path]);
68
79
  function drawPolygon() {
69
80
  var polygonObj = {
70
81
  id: id,
@@ -82,7 +93,6 @@ var MapPolygon = function MapPolygon(props) {
82
93
  map.setPaintProperty(id, 'fill-color', color);
83
94
  map.setPaintProperty(id, 'fill-opacity', opacity);
84
95
  } else {
85
- // console.log('添加layer');
86
96
  map.addLayer(polygonObj);
87
97
  }
88
98
  setPolygon(polygonObj);
@@ -29,8 +29,8 @@ function findKeyWithMinValueGreaterThan(obj, a) {
29
29
  }
30
30
  var MapPolyline = function MapPolyline(props) {
31
31
  var map = props.map,
32
- _props$position = props.position,
33
- position = _props$position === void 0 ? [] : _props$position,
32
+ _props$path = props.path,
33
+ path = _props$path === void 0 ? [] : _props$path,
34
34
  _props$color = props.color,
35
35
  color = _props$color === void 0 ? '#00A4B2' : _props$color,
36
36
  _props$lineEndColor = props.lineEndColor,
@@ -83,7 +83,7 @@ var MapPolyline = function MapPolyline(props) {
83
83
  var sourceDataObj;
84
84
  if (multi) {
85
85
  var features = [];
86
- position.forEach(function (item) {
86
+ path.forEach(function (item) {
87
87
  features.push({
88
88
  type: 'Feature',
89
89
  properties: item,
@@ -98,7 +98,7 @@ var MapPolyline = function MapPolyline(props) {
98
98
  features: features
99
99
  };
100
100
  } else {
101
- var coordinates = position;
101
+ var coordinates = path;
102
102
  sourceDataObj = {
103
103
  type: 'FeatureCollection',
104
104
  features: [{
@@ -124,7 +124,7 @@ var MapPolyline = function MapPolyline(props) {
124
124
  });
125
125
  }
126
126
  setSourceData(sourceDataObj);
127
- }, [map, position]);
127
+ }, [map, path]);
128
128
  useEffect(function () {
129
129
  if (map && line) {
130
130
  var lineColor = color;
@@ -154,7 +154,6 @@ var MapPolyline = function MapPolyline(props) {
154
154
  var obj = {};
155
155
  layers.forEach(function (item) {
156
156
  var _item$metadata;
157
- // @ts-ignore
158
157
  obj[item.id] = (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.zIndex;
159
158
  });
160
159
  var fKey = findKeyWithMinValueGreaterThan(obj, zIndex, [id]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepinnet-components/pc",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",