@deepinnet-components/pc 0.0.52 → 0.0.54
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.
package/dist/Map2D/Map/index.js
CHANGED
|
@@ -15,7 +15,9 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
15
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
16
|
// @ts-nocheck
|
|
17
17
|
import { useEffect, useRef, useState } from 'react';
|
|
18
|
+
import arrowImg from "../demo/imgs/\u7BAD\u5934\u65B9\u5411.png";
|
|
18
19
|
import "../index.less";
|
|
20
|
+
import { getBase64FromLocalImage } from "../utils";
|
|
19
21
|
var Map = function Map(props) {
|
|
20
22
|
var id = props.id,
|
|
21
23
|
_props$opts = props.opts,
|
|
@@ -96,6 +98,26 @@ var Map = function Map(props) {
|
|
|
96
98
|
if (props.onRightClick) {
|
|
97
99
|
map === null || map === void 0 || map.on('contextmenu', mapRightClick);
|
|
98
100
|
}
|
|
101
|
+
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
102
|
+
var base64, image;
|
|
103
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
104
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
105
|
+
case 0:
|
|
106
|
+
_context2.next = 2;
|
|
107
|
+
return getBase64FromLocalImage(arrowImg);
|
|
108
|
+
case 2:
|
|
109
|
+
base64 = _context2.sent;
|
|
110
|
+
_context2.next = 5;
|
|
111
|
+
return map.loadImage(base64);
|
|
112
|
+
case 5:
|
|
113
|
+
image = _context2.sent;
|
|
114
|
+
map.addImage('custom-arrow', image.data);
|
|
115
|
+
case 7:
|
|
116
|
+
case "end":
|
|
117
|
+
return _context2.stop();
|
|
118
|
+
}
|
|
119
|
+
}, _callee2);
|
|
120
|
+
}))();
|
|
99
121
|
}
|
|
100
122
|
}, [map]);
|
|
101
123
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -50,6 +50,12 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
50
50
|
zIndex = _props$zIndex === void 0 ? 12 : _props$zIndex,
|
|
51
51
|
_props$isArrow = props.isArrow,
|
|
52
52
|
isArrow = _props$isArrow === void 0 ? false : _props$isArrow,
|
|
53
|
+
_props$arrowConfig = props.arrowConfig,
|
|
54
|
+
arrowConfig = _props$arrowConfig === void 0 ? {
|
|
55
|
+
img: 'custom-arrow',
|
|
56
|
+
spacing: 25,
|
|
57
|
+
size: 1
|
|
58
|
+
} : _props$arrowConfig,
|
|
53
59
|
_props$multi = props.multi,
|
|
54
60
|
multi = _props$multi === void 0 ? false : _props$multi,
|
|
55
61
|
_props$isGetColor = props.isGetColor,
|
|
@@ -158,23 +164,25 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
158
164
|
obj[item.id] = (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.zIndex;
|
|
159
165
|
});
|
|
160
166
|
var fKey = findKeyWithMinValueGreaterThan(obj, zIndex, [id]);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
167
|
+
try {
|
|
168
|
+
if (fKey) {
|
|
169
|
+
map.moveLayer(id, fKey);
|
|
170
|
+
if (getOutline()) {
|
|
171
|
+
map.moveLayer(outlineId, fKey);
|
|
172
|
+
}
|
|
173
|
+
if (getArrowLine()) {
|
|
174
|
+
map.moveLayer(allowLayerId, fKey);
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
map.moveLayer(id);
|
|
178
|
+
if (getOutline()) {
|
|
179
|
+
map.moveLayer(outlineId);
|
|
180
|
+
}
|
|
181
|
+
if (getArrowLine()) {
|
|
182
|
+
map.moveLayer(allowLayerId);
|
|
183
|
+
}
|
|
176
184
|
}
|
|
177
|
-
}
|
|
185
|
+
} catch (error) {}
|
|
178
186
|
}
|
|
179
187
|
}, [zIndex, map, line]);
|
|
180
188
|
useEffect(function () {
|
|
@@ -203,7 +211,8 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
203
211
|
},
|
|
204
212
|
zIndex: zIndex,
|
|
205
213
|
metadata: {
|
|
206
|
-
zIndex: zIndex
|
|
214
|
+
zIndex: zIndex,
|
|
215
|
+
isArrow: isArrow
|
|
207
216
|
}
|
|
208
217
|
};
|
|
209
218
|
if (multi && isGetColor) {
|
|
@@ -223,21 +232,20 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
223
232
|
map.setPaintProperty(id, 'line-color', lineColor);
|
|
224
233
|
map.setPaintProperty(id, 'line-width', width);
|
|
225
234
|
map.setPaintProperty(id, 'line-opacity', opacity);
|
|
226
|
-
} else {
|
|
227
|
-
// console.log('添加layer')
|
|
228
|
-
map.addLayer(lineObj);
|
|
229
235
|
if (isArrow) {
|
|
236
|
+
var arrowLayer = map.getLayer(allowLayerId);
|
|
237
|
+
if (arrowLayer) return;
|
|
230
238
|
var arrowLineObj = {
|
|
231
239
|
id: allowLayerId,
|
|
232
240
|
type: 'symbol',
|
|
233
241
|
source: id,
|
|
234
242
|
layout: {
|
|
235
|
-
'icon-image': 'custom-arrow',
|
|
243
|
+
'icon-image': arrowConfig.img || 'custom-arrow',
|
|
236
244
|
// 箭头图标
|
|
237
245
|
'symbol-placement': 'line',
|
|
238
|
-
'symbol-spacing': 25,
|
|
246
|
+
'symbol-spacing': arrowConfig.spacing || 25,
|
|
239
247
|
// 图标间隔,默认为250
|
|
240
|
-
'icon-size': 1
|
|
248
|
+
'icon-size': arrowConfig.size || 1
|
|
241
249
|
},
|
|
242
250
|
metadata: {
|
|
243
251
|
zIndex: zIndex
|
|
@@ -245,6 +253,34 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
245
253
|
};
|
|
246
254
|
map.addLayer(arrowLineObj);
|
|
247
255
|
setArrowLine(arrowLineObj);
|
|
256
|
+
} else {
|
|
257
|
+
var _arrowLayer = map.getLayer(allowLayerId);
|
|
258
|
+
if (_arrowLayer) {
|
|
259
|
+
map === null || map === void 0 || map.removeLayer(allowLayerId);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
} else {
|
|
263
|
+
// console.log('添加layer')
|
|
264
|
+
map.addLayer(lineObj);
|
|
265
|
+
if (isArrow) {
|
|
266
|
+
var _arrowLineObj = {
|
|
267
|
+
id: allowLayerId,
|
|
268
|
+
type: 'symbol',
|
|
269
|
+
source: id,
|
|
270
|
+
layout: {
|
|
271
|
+
'icon-image': arrowConfig.img || 'custom-arrow',
|
|
272
|
+
// 箭头图标
|
|
273
|
+
'symbol-placement': 'line',
|
|
274
|
+
'symbol-spacing': arrowConfig.spacing || 25,
|
|
275
|
+
// 图标间隔,默认为250
|
|
276
|
+
'icon-size': arrowConfig.size || 1
|
|
277
|
+
},
|
|
278
|
+
metadata: {
|
|
279
|
+
zIndex: zIndex
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
map.addLayer(_arrowLineObj);
|
|
283
|
+
setArrowLine(_arrowLineObj);
|
|
248
284
|
}
|
|
249
285
|
}
|
|
250
286
|
setLine(deepClone(lineObj));
|
|
@@ -296,7 +332,7 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
296
332
|
if (!map || !sourceData) return;
|
|
297
333
|
drawLine();
|
|
298
334
|
drawOutLine();
|
|
299
|
-
}, [map, sourceData, color, width, opacity, isOutline]);
|
|
335
|
+
}, [map, sourceData, color, width, opacity, isOutline, isArrow]);
|
|
300
336
|
var flagRef = useRef(false);
|
|
301
337
|
function onMouseenter(e) {
|
|
302
338
|
if (flagRef.current) return;
|
|
@@ -322,7 +358,7 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
322
358
|
var _e$originalEvent, _e$originalEvent$stop;
|
|
323
359
|
(_e$originalEvent = e.originalEvent) === null || _e$originalEvent === void 0 || (_e$originalEvent$stop = _e$originalEvent.stopPropagation) === null || _e$originalEvent$stop === void 0 || _e$originalEvent$stop.call(_e$originalEvent);
|
|
324
360
|
var features = map.queryRenderedFeatures(e.point);
|
|
325
|
-
console.log(features);
|
|
361
|
+
// console.log(features);
|
|
326
362
|
if (!features.length) return;
|
|
327
363
|
var item = features.find(function (item) {
|
|
328
364
|
return item.source.includes('customPolyline::');
|
|
@@ -5,10 +5,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
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
7
|
import { Map2D } from "../../..";
|
|
8
|
-
import { Button,
|
|
8
|
+
import { Button, message } from 'antd';
|
|
9
9
|
import React, { useEffect, useState } from 'react';
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
|
|
12
10
|
var Map = Map2D.Map,
|
|
13
11
|
MapMarker = Map2D.MapMarker,
|
|
14
12
|
MapPolygon = Map2D.MapPolygon,
|
|
@@ -165,9 +163,6 @@ var App = function App() {
|
|
|
165
163
|
onClick: function onClick() {
|
|
166
164
|
message.info('centerOfMass中心');
|
|
167
165
|
}
|
|
168
|
-
}))))
|
|
169
|
-
type: "primary",
|
|
170
|
-
onClick: function onClick() {}
|
|
171
|
-
}, "btn")));
|
|
166
|
+
})))));
|
|
172
167
|
};
|
|
173
168
|
export default App;
|