@deepinnet-components/pc 0.0.40 → 0.0.42
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/AuthTreeManage/AuthManagePage/index.js +5 -1
- package/dist/Map2D/MapMarker/index.js +7 -8
- package/dist/Map2D/MapMarkerMulti/index.d.ts +2 -0
- package/dist/Map2D/MapMarkerMulti/index.js +178 -0
- package/dist/Map2D/MapPolygon/index.js +14 -4
- package/dist/Map2D/MapPolyline/index.js +69 -27
- package/dist/Map2D/index.d.ts +3 -0
- package/dist/Map2D/index.js +5 -1
- package/dist/Map2D/utils.d.ts +9 -0
- package/dist/Map2D/utils.js +269 -1
- package/dist/SuperAdminCreate/CreatePage/index.js +21 -7
- package/package.json +4 -2
|
@@ -141,7 +141,11 @@ var Index = function Index() {
|
|
|
141
141
|
expandedRowKeys = _useState8[0],
|
|
142
142
|
setExpandedRowKeys = _useState8[1];
|
|
143
143
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
144
|
-
|
|
144
|
+
style: {
|
|
145
|
+
color: '#f00',
|
|
146
|
+
fontSize: 20,
|
|
147
|
+
marginBottom: 20
|
|
148
|
+
}
|
|
145
149
|
}, "\u8BE5\u529F\u80FD\u8BF7\u8C28\u614E\u64CD\u4F5C\uFF0C\u975E\u5FC5\u8981\u4E0D\u53EF\u64CD\u4F5C\uFF0C\u64CD\u4F5C\u524D\u9700\u8BE2\u95EE\u5F00\u53D1\u3002"), /*#__PURE__*/React.createElement(ShenduTable, {
|
|
146
150
|
actionRef: tableRef
|
|
147
151
|
// search={{
|
|
@@ -10,8 +10,7 @@ import React, { memo, useEffect, useRef, useState } from 'react';
|
|
|
10
10
|
import shortid from 'shortid';
|
|
11
11
|
var MapMarker = function MapMarker(props) {
|
|
12
12
|
var map = props.map,
|
|
13
|
-
|
|
14
|
-
pos = props.pos,
|
|
13
|
+
position = props.position,
|
|
15
14
|
_props$offset = props.offset,
|
|
16
15
|
offset = _props$offset === void 0 ? [0, 0] : _props$offset,
|
|
17
16
|
_props$zIndex = props.zIndex,
|
|
@@ -19,7 +18,7 @@ var MapMarker = function MapMarker(props) {
|
|
|
19
18
|
_props$draggable = props.draggable,
|
|
20
19
|
draggable = _props$draggable === void 0 ? false : _props$draggable,
|
|
21
20
|
children = props.children;
|
|
22
|
-
var _useState = useState('customMarker::' +
|
|
21
|
+
var _useState = useState('customMarker::' + shortid.generate()),
|
|
23
22
|
_useState2 = _slicedToArray(_useState, 1),
|
|
24
23
|
id = _useState2[0];
|
|
25
24
|
var somePropsRef = useRef();
|
|
@@ -50,7 +49,7 @@ var MapMarker = function MapMarker(props) {
|
|
|
50
49
|
var el = domRef.current;
|
|
51
50
|
var newMarker = getMarker();
|
|
52
51
|
var somePropsObj = {
|
|
53
|
-
|
|
52
|
+
position: position,
|
|
54
53
|
offset: offset,
|
|
55
54
|
draggable: draggable
|
|
56
55
|
};
|
|
@@ -61,8 +60,8 @@ var MapMarker = function MapMarker(props) {
|
|
|
61
60
|
if (isEqual(somePropsObj, somePropsRef.current)) return;
|
|
62
61
|
|
|
63
62
|
// 只在位置真正发生变化时更新
|
|
64
|
-
if (!isEqual(
|
|
65
|
-
newMarker.setLngLat([Number(
|
|
63
|
+
if (!isEqual(position, (_somePropsRef$current = somePropsRef.current) === null || _somePropsRef$current === void 0 ? void 0 : _somePropsRef$current.position) || !isEqual(offset, (_somePropsRef$current2 = somePropsRef.current) === null || _somePropsRef$current2 === void 0 ? void 0 : _somePropsRef$current2.offset)) {
|
|
64
|
+
newMarker.setLngLat([Number(position[0]), Number(position[1])]).setOffset(offset).setDraggable(draggable);
|
|
66
65
|
somePropsRef.current = somePropsObj;
|
|
67
66
|
}
|
|
68
67
|
} else {
|
|
@@ -77,7 +76,7 @@ var MapMarker = function MapMarker(props) {
|
|
|
77
76
|
}
|
|
78
77
|
newMarker = new mapabcgl.Marker({
|
|
79
78
|
element: el
|
|
80
|
-
}).setLngLat([Number(
|
|
79
|
+
}).setLngLat([Number(position[0]), Number(position[1])]).setOffset(offset).setDraggable(draggable).addTo(map);
|
|
81
80
|
if (draggable) {
|
|
82
81
|
newMarker.on('drag', onDrag);
|
|
83
82
|
}
|
|
@@ -90,7 +89,7 @@ var MapMarker = function MapMarker(props) {
|
|
|
90
89
|
// @ts-ignore
|
|
91
90
|
window.customMarkers[id] = newMarker;
|
|
92
91
|
}
|
|
93
|
-
}, [map,
|
|
92
|
+
}, [map, position, offset, draggable]);
|
|
94
93
|
useEffect(function () {
|
|
95
94
|
if (!map) return;
|
|
96
95
|
return function () {
|
|
@@ -0,0 +1,178 @@
|
|
|
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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
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
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import { useEffect, useState, memo } from 'react';
|
|
12
|
+
import { useGetState } from 'ahooks';
|
|
13
|
+
import { isEqual } from 'lodash-es';
|
|
14
|
+
import shortid from 'shortid';
|
|
15
|
+
import { getBase64FromLocalImage } from "../utils";
|
|
16
|
+
var MapMarkerMulti = function MapMarkerMulti(props) {
|
|
17
|
+
var map = props.map,
|
|
18
|
+
_props$position = props.position,
|
|
19
|
+
position = _props$position === void 0 ? [] : _props$position,
|
|
20
|
+
_props$img = props.img,
|
|
21
|
+
img = _props$img === void 0 ? '' : _props$img,
|
|
22
|
+
_props$size = props.size,
|
|
23
|
+
size = _props$size === void 0 ? 1 : _props$size,
|
|
24
|
+
_props$offset = props.offset,
|
|
25
|
+
offset = _props$offset === void 0 ? [0, 0] : _props$offset,
|
|
26
|
+
_props$offsetAnchor = props.offsetAnchor,
|
|
27
|
+
offsetAnchor = _props$offsetAnchor === void 0 ? 'center' : _props$offsetAnchor,
|
|
28
|
+
_props$multi = props.multi,
|
|
29
|
+
multi = _props$multi === void 0 ? false : _props$multi;
|
|
30
|
+
var _useState = useState('customMarkerSymbol::' + (props.id || shortid.generate())),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
32
|
+
id = _useState2[0];
|
|
33
|
+
var _useGetState = useGetState(),
|
|
34
|
+
_useGetState2 = _slicedToArray(_useGetState, 3),
|
|
35
|
+
sourceData = _useGetState2[0],
|
|
36
|
+
setSourceData = _useGetState2[1],
|
|
37
|
+
getSourceData = _useGetState2[2];
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
if (!map) return;
|
|
40
|
+
var sourceDataObj;
|
|
41
|
+
if (multi) {
|
|
42
|
+
var features = [];
|
|
43
|
+
position.forEach(function (item) {
|
|
44
|
+
features.push({
|
|
45
|
+
type: 'Feature',
|
|
46
|
+
properties: item,
|
|
47
|
+
geometry: {
|
|
48
|
+
type: 'Point',
|
|
49
|
+
coordinates: item.position
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
sourceDataObj = {
|
|
54
|
+
type: 'FeatureCollection',
|
|
55
|
+
features: features
|
|
56
|
+
};
|
|
57
|
+
} else {
|
|
58
|
+
var coordinates = position;
|
|
59
|
+
sourceDataObj = {
|
|
60
|
+
type: 'FeatureCollection',
|
|
61
|
+
features: [{
|
|
62
|
+
type: 'Feature',
|
|
63
|
+
geometry: {
|
|
64
|
+
type: 'Point',
|
|
65
|
+
coordinates: coordinates
|
|
66
|
+
}
|
|
67
|
+
}]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (isEqual(getSourceData(), sourceDataObj)) return;
|
|
71
|
+
var source = map.getSource(id);
|
|
72
|
+
if (source) {
|
|
73
|
+
// console.log('更新source')
|
|
74
|
+
source.setData(sourceDataObj);
|
|
75
|
+
} else {
|
|
76
|
+
// console.log('添加source')
|
|
77
|
+
map.addSource(id, {
|
|
78
|
+
type: 'geojson',
|
|
79
|
+
data: sourceDataObj
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
setSourceData(sourceDataObj);
|
|
83
|
+
}, [map, position]);
|
|
84
|
+
function drawMarker() {
|
|
85
|
+
return _drawMarker.apply(this, arguments);
|
|
86
|
+
}
|
|
87
|
+
function _drawMarker() {
|
|
88
|
+
_drawMarker = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
89
|
+
var base64, image, markerObj;
|
|
90
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
91
|
+
while (1) switch (_context.prev = _context.next) {
|
|
92
|
+
case 0:
|
|
93
|
+
_context.next = 2;
|
|
94
|
+
return getBase64FromLocalImage(img);
|
|
95
|
+
case 2:
|
|
96
|
+
base64 = _context.sent;
|
|
97
|
+
_context.next = 5;
|
|
98
|
+
return map.loadImage(base64);
|
|
99
|
+
case 5:
|
|
100
|
+
image = _context.sent;
|
|
101
|
+
map.addImage("markerImg_".concat(id), image.data);
|
|
102
|
+
markerObj = {
|
|
103
|
+
id: id,
|
|
104
|
+
type: 'symbol',
|
|
105
|
+
source: id,
|
|
106
|
+
layout: {
|
|
107
|
+
'icon-image': "markerImg_".concat(id),
|
|
108
|
+
'icon-size': size,
|
|
109
|
+
'icon-allow-overlap': true,
|
|
110
|
+
'icon-offset': offset,
|
|
111
|
+
'icon-anchor': offsetAnchor
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
map.addLayer(markerObj);
|
|
115
|
+
case 9:
|
|
116
|
+
case "end":
|
|
117
|
+
return _context.stop();
|
|
118
|
+
}
|
|
119
|
+
}, _callee);
|
|
120
|
+
}));
|
|
121
|
+
return _drawMarker.apply(this, arguments);
|
|
122
|
+
}
|
|
123
|
+
useEffect(function () {
|
|
124
|
+
if (!map || !sourceData) return;
|
|
125
|
+
drawMarker();
|
|
126
|
+
}, [map, sourceData]);
|
|
127
|
+
function onClick(e) {
|
|
128
|
+
var _e$originalEvent, _e$originalEvent$stop;
|
|
129
|
+
(_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);
|
|
130
|
+
var features = map.queryRenderedFeatures(e.point);
|
|
131
|
+
if (!features.length) return;
|
|
132
|
+
var item = features.find(function (item) {
|
|
133
|
+
return item.source.includes('customMarkerSymbol::');
|
|
134
|
+
});
|
|
135
|
+
if (item && item.source === id) {
|
|
136
|
+
var _props$onClick;
|
|
137
|
+
(_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, features[0]);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function onRightClick(e) {
|
|
141
|
+
var _e$stopPropagation;
|
|
142
|
+
(_e$stopPropagation = e.stopPropagation) === null || _e$stopPropagation === void 0 || _e$stopPropagation.call(e);
|
|
143
|
+
var features = map.queryRenderedFeatures(e.point);
|
|
144
|
+
if (!features.length) return;
|
|
145
|
+
var item = features.find(function (item) {
|
|
146
|
+
return item.source.includes('customMarkerSymbol::');
|
|
147
|
+
});
|
|
148
|
+
if (item && item.source === id) {
|
|
149
|
+
var _props$onRightClick;
|
|
150
|
+
(_props$onRightClick = props.onRightClick) === null || _props$onRightClick === void 0 || _props$onRightClick.call(props, features[0]);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 事件处理
|
|
155
|
+
useEffect(function () {
|
|
156
|
+
if (map) {
|
|
157
|
+
if (props.onClick) {
|
|
158
|
+
map.on('click', id, onClick);
|
|
159
|
+
}
|
|
160
|
+
if (props.onRightClick) {
|
|
161
|
+
map.on('contextmenu', id, onRightClick);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}, [map]);
|
|
165
|
+
useEffect(function () {
|
|
166
|
+
return function () {
|
|
167
|
+
map === null || map === void 0 || map.removeLayerAndSource(id);
|
|
168
|
+
map === null || map === void 0 || map.off('click', id, onClick);
|
|
169
|
+
map === null || map === void 0 || map.off('contextmenu', id, onClick);
|
|
170
|
+
};
|
|
171
|
+
}, []);
|
|
172
|
+
return null;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// export default MapPolyline
|
|
176
|
+
|
|
177
|
+
var memoCom = /*#__PURE__*/memo(MapMarkerMulti);
|
|
178
|
+
export default memoCom;
|
|
@@ -10,8 +10,8 @@ import { isEqual } from 'lodash-es';
|
|
|
10
10
|
import shortid from 'shortid';
|
|
11
11
|
var MapPolygon = function MapPolygon(props) {
|
|
12
12
|
var map = props.map,
|
|
13
|
-
_props$
|
|
14
|
-
|
|
13
|
+
_props$position = props.position,
|
|
14
|
+
position = _props$position === void 0 ? [] : _props$position,
|
|
15
15
|
_props$color = props.color,
|
|
16
16
|
color = _props$color === void 0 ? '#1890ff' : _props$color,
|
|
17
17
|
_props$opacity = props.opacity,
|
|
@@ -37,11 +37,21 @@ var MapPolygon = function MapPolygon(props) {
|
|
|
37
37
|
type: 'Feature',
|
|
38
38
|
geometry: {
|
|
39
39
|
type: 'Polygon',
|
|
40
|
-
coordinates: [
|
|
40
|
+
coordinates: [position]
|
|
41
41
|
}
|
|
42
42
|
}]
|
|
43
43
|
};
|
|
44
44
|
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
|
+
};
|
|
45
55
|
var source = map.getSource(id);
|
|
46
56
|
if (source) {
|
|
47
57
|
// console.log('更新source');
|
|
@@ -54,7 +64,7 @@ var MapPolygon = function MapPolygon(props) {
|
|
|
54
64
|
});
|
|
55
65
|
}
|
|
56
66
|
setSourceData(sourceDataObj);
|
|
57
|
-
}, [map,
|
|
67
|
+
}, [map, position]);
|
|
58
68
|
function drawPolygon() {
|
|
59
69
|
var polygonObj = {
|
|
60
70
|
id: id,
|
|
@@ -9,10 +9,14 @@ import { useGetState } from 'ahooks';
|
|
|
9
9
|
import { isEqual } from 'lodash-es';
|
|
10
10
|
import shortid from 'shortid';
|
|
11
11
|
import { getAllLineLayers } from "../utils";
|
|
12
|
+
import { deepClone } from "../utils";
|
|
12
13
|
function findKeyWithMinValueGreaterThan(obj, a) {
|
|
14
|
+
var ignoreKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
13
15
|
var minValue = Infinity;
|
|
14
16
|
var resultKey = null;
|
|
15
17
|
for (var key in obj) {
|
|
18
|
+
// if (!ignoreKeys.includes(key) && obj.hasOwnProperty(key)) {
|
|
19
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
16
20
|
if (obj.hasOwnProperty(key)) {
|
|
17
21
|
var val = obj[key];
|
|
18
22
|
if (val > a && val < minValue) {
|
|
@@ -25,8 +29,8 @@ function findKeyWithMinValueGreaterThan(obj, a) {
|
|
|
25
29
|
}
|
|
26
30
|
var MapPolyline = function MapPolyline(props) {
|
|
27
31
|
var map = props.map,
|
|
28
|
-
_props$
|
|
29
|
-
|
|
32
|
+
_props$position = props.position,
|
|
33
|
+
position = _props$position === void 0 ? [] : _props$position,
|
|
30
34
|
_props$color = props.color,
|
|
31
35
|
color = _props$color === void 0 ? '#00A4B2' : _props$color,
|
|
32
36
|
_props$lineEndColor = props.lineEndColor,
|
|
@@ -46,7 +50,9 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
46
50
|
_props$zIndex = props.zIndex,
|
|
47
51
|
zIndex = _props$zIndex === void 0 ? 12 : _props$zIndex,
|
|
48
52
|
_props$isArrow = props.isArrow,
|
|
49
|
-
isArrow = _props$isArrow === void 0 ? false : _props$isArrow
|
|
53
|
+
isArrow = _props$isArrow === void 0 ? false : _props$isArrow,
|
|
54
|
+
_props$multi = props.multi,
|
|
55
|
+
multi = _props$multi === void 0 ? false : _props$multi;
|
|
50
56
|
var _useState = useState('customLine::' + (props.id || shortid.generate())),
|
|
51
57
|
_useState2 = _slicedToArray(_useState, 1),
|
|
52
58
|
id = _useState2[0];
|
|
@@ -74,16 +80,36 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
74
80
|
getArrowLine = _useGetState8[2];
|
|
75
81
|
useEffect(function () {
|
|
76
82
|
if (!map) return;
|
|
77
|
-
var sourceDataObj
|
|
78
|
-
|
|
79
|
-
features
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
type: '
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
var sourceDataObj;
|
|
84
|
+
if (multi) {
|
|
85
|
+
var features = [];
|
|
86
|
+
position.forEach(function (item) {
|
|
87
|
+
features.push({
|
|
88
|
+
type: 'Feature',
|
|
89
|
+
properties: item,
|
|
90
|
+
geometry: {
|
|
91
|
+
type: 'LineString',
|
|
92
|
+
coordinates: item.position
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
sourceDataObj = {
|
|
97
|
+
type: 'FeatureCollection',
|
|
98
|
+
features: features
|
|
99
|
+
};
|
|
100
|
+
} else {
|
|
101
|
+
var coordinates = position;
|
|
102
|
+
sourceDataObj = {
|
|
103
|
+
type: 'FeatureCollection',
|
|
104
|
+
features: [{
|
|
105
|
+
type: 'Feature',
|
|
106
|
+
geometry: {
|
|
107
|
+
type: 'LineString',
|
|
108
|
+
coordinates: coordinates
|
|
109
|
+
}
|
|
110
|
+
}]
|
|
111
|
+
};
|
|
112
|
+
}
|
|
87
113
|
if (isEqual(getSourceData(), sourceDataObj)) return;
|
|
88
114
|
var source = map.getSource(id);
|
|
89
115
|
if (source) {
|
|
@@ -98,9 +124,13 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
98
124
|
});
|
|
99
125
|
}
|
|
100
126
|
setSourceData(sourceDataObj);
|
|
101
|
-
}, [map,
|
|
127
|
+
}, [map, position]);
|
|
102
128
|
useEffect(function () {
|
|
103
129
|
if (map && line) {
|
|
130
|
+
var lineColor = color;
|
|
131
|
+
if (multi) {
|
|
132
|
+
lineColor = ['get', 'color'];
|
|
133
|
+
}
|
|
104
134
|
var lineObj = {
|
|
105
135
|
id: id,
|
|
106
136
|
type: 'line',
|
|
@@ -110,7 +140,7 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
110
140
|
'line-cap': 'round'
|
|
111
141
|
},
|
|
112
142
|
paint: {
|
|
113
|
-
'line-color':
|
|
143
|
+
'line-color': lineColor,
|
|
114
144
|
'line-width': width,
|
|
115
145
|
'line-opacity': opacity
|
|
116
146
|
},
|
|
@@ -123,9 +153,11 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
123
153
|
var layers = getAllLineLayers(map);
|
|
124
154
|
var obj = {};
|
|
125
155
|
layers.forEach(function (item) {
|
|
126
|
-
|
|
156
|
+
var _item$metadata;
|
|
157
|
+
// @ts-ignore
|
|
158
|
+
obj[item.id] = (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.zIndex;
|
|
127
159
|
});
|
|
128
|
-
var fKey = findKeyWithMinValueGreaterThan(obj, zIndex);
|
|
160
|
+
var fKey = findKeyWithMinValueGreaterThan(obj, zIndex, [id]);
|
|
129
161
|
if (fKey) {
|
|
130
162
|
map.moveLayer(id, fKey);
|
|
131
163
|
if (getOutline()) {
|
|
@@ -174,6 +206,9 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
174
206
|
zIndex: zIndex
|
|
175
207
|
}
|
|
176
208
|
};
|
|
209
|
+
if (multi) {
|
|
210
|
+
lineObj.paint['line-color'] = ['get', 'color'];
|
|
211
|
+
}
|
|
177
212
|
if (lineEndColor) {
|
|
178
213
|
lineObj.paint['line-gradient'] = ['interpolate', ['linear'], ['line-progress'], 0, color, 1, lineEndColor];
|
|
179
214
|
}
|
|
@@ -181,7 +216,11 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
181
216
|
var layer = map.getLayer(id);
|
|
182
217
|
if (layer) {
|
|
183
218
|
// console.log('更新layer')
|
|
184
|
-
|
|
219
|
+
var lineColor = color;
|
|
220
|
+
if (multi) {
|
|
221
|
+
lineColor = ['get', 'color'];
|
|
222
|
+
}
|
|
223
|
+
map.setPaintProperty(id, 'line-color', lineColor);
|
|
185
224
|
map.setPaintProperty(id, 'line-width', width);
|
|
186
225
|
map.setPaintProperty(id, 'line-opacity', opacity);
|
|
187
226
|
} else {
|
|
@@ -208,7 +247,7 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
208
247
|
setArrowLine(arrowLineObj);
|
|
209
248
|
}
|
|
210
249
|
}
|
|
211
|
-
setLine(
|
|
250
|
+
setLine(deepClone(lineObj));
|
|
212
251
|
}
|
|
213
252
|
function drawOutLine() {
|
|
214
253
|
var outlineObj = {
|
|
@@ -280,6 +319,8 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
280
319
|
(_props$onMouseleave = props.onMouseleave) === null || _props$onMouseleave === void 0 || _props$onMouseleave.call(props, e);
|
|
281
320
|
}
|
|
282
321
|
function onClick(e) {
|
|
322
|
+
var _e$originalEvent, _e$originalEvent$stop;
|
|
323
|
+
(_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);
|
|
283
324
|
var features = map.queryRenderedFeatures(e.point);
|
|
284
325
|
if (!features.length) return;
|
|
285
326
|
var item = features.find(function (item) {
|
|
@@ -323,14 +364,15 @@ var MapPolyline = function MapPolyline(props) {
|
|
|
323
364
|
}, [map]);
|
|
324
365
|
useEffect(function () {
|
|
325
366
|
return function () {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
367
|
+
try {
|
|
368
|
+
map === null || map === void 0 || map.removeLayerAndSource(allowLayerId);
|
|
369
|
+
map === null || map === void 0 || map.removeLayerAndSource(outlineId);
|
|
370
|
+
map === null || map === void 0 || map.removeLayerAndSource(id);
|
|
371
|
+
map === null || map === void 0 || map.off('mouseenter', id, onMouseenter);
|
|
372
|
+
map === null || map === void 0 || map.off('mouseleave', id, onMouseleave);
|
|
373
|
+
map === null || map === void 0 || map.off('click', id, onClick);
|
|
374
|
+
map === null || map === void 0 || map.off('contextmenu', id, onClick);
|
|
375
|
+
} catch (error) {}
|
|
334
376
|
};
|
|
335
377
|
}, []);
|
|
336
378
|
return null;
|
package/dist/Map2D/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import * as Utils from './utils';
|
|
2
3
|
declare const Map2D: {
|
|
3
4
|
MapMarker: import("react").MemoExoticComponent<(props: any) => import("react").JSX.Element>;
|
|
5
|
+
MapMarkerMulti: any;
|
|
4
6
|
MapPolyline: any;
|
|
5
7
|
MapPolygon: any;
|
|
8
|
+
Utils: typeof Utils;
|
|
6
9
|
};
|
|
7
10
|
export default Map2D;
|
package/dist/Map2D/index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
// import Map from './Map';
|
|
2
2
|
import MapMarker from "./MapMarker";
|
|
3
|
+
import MapMarkerMulti from "./MapMarkerMulti";
|
|
3
4
|
import MapPolyline from "./MapPolyline";
|
|
4
5
|
import MapPolygon from "./MapPolygon";
|
|
6
|
+
import * as Utils from "./utils";
|
|
5
7
|
var Map2D = {
|
|
6
8
|
// Map,
|
|
7
9
|
MapMarker: MapMarker,
|
|
10
|
+
MapMarkerMulti: MapMarkerMulti,
|
|
8
11
|
MapPolyline: MapPolyline,
|
|
9
|
-
MapPolygon: MapPolygon
|
|
12
|
+
MapPolygon: MapPolygon,
|
|
13
|
+
Utils: Utils
|
|
10
14
|
};
|
|
11
15
|
export default Map2D;
|
package/dist/Map2D/utils.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
1
|
export declare function getAllLineLayers(map: any): any;
|
|
2
|
+
export declare function getTargetLayers(map: any, layerIds: any): any;
|
|
3
|
+
export declare function setFitView(map: any, padding?: any): void;
|
|
4
|
+
export declare function setFitViewByMarker(map: any, padding: any, markerId: any): void;
|
|
5
|
+
export declare function setFitViewByPolylineOrPolygon(map: any, padding: any, layerIds: any): void;
|
|
6
|
+
export declare const getAutoLinePos: (map: any, options: any) => Promise<unknown>;
|
|
7
|
+
export declare const transformAreaData: (data: any) => any;
|
|
8
|
+
export declare const isValidLngLat: (data: any) => boolean;
|
|
9
|
+
export declare const deepClone: (obj: any) => any;
|
|
10
|
+
export declare const getBase64FromLocalImage: (url: any) => Promise<unknown>;
|
package/dist/Map2D/utils.js
CHANGED
|
@@ -1,8 +1,276 @@
|
|
|
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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
// @ts-nocheck
|
|
6
|
+
import { isEmpty } from 'lodash-es';
|
|
7
|
+
import wellknown from 'wellknown';
|
|
8
|
+
import { cloneDeepWith } from 'lodash-es';
|
|
9
|
+
|
|
1
10
|
// 获取所有自定义折线图层的函数
|
|
2
11
|
export function getAllLineLayers(map) {
|
|
3
12
|
var layers = map.getStyle().layers;
|
|
13
|
+
// console.log(layers, 'allLayers')
|
|
4
14
|
var lineLayers = layers.filter(function (layer) {
|
|
5
15
|
if (layer.id.includes('customLine::')) return true;
|
|
16
|
+
if (layer.id.includes('customPolygon::')) return true;
|
|
6
17
|
});
|
|
7
18
|
return lineLayers;
|
|
8
|
-
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 获取自定义折线/区域图层的函数
|
|
22
|
+
export function getTargetLayers(map, layerIds) {
|
|
23
|
+
var layers = map.getStyle().layers;
|
|
24
|
+
var lineLayers = layers.filter(function (layer) {
|
|
25
|
+
if (layerIds.includes(layer.id)) return true;
|
|
26
|
+
});
|
|
27
|
+
return lineLayers;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 获取所有marker的函数
|
|
31
|
+
function getAllMarkers(bounds) {
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
if (window.customMarkers) {
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
var markers = Object.values(window.customMarkers);
|
|
36
|
+
|
|
37
|
+
// 假设 markers 是存储标记对象的数组
|
|
38
|
+
markers.forEach(function (marker) {
|
|
39
|
+
var lngLat = marker.getLngLat();
|
|
40
|
+
bounds.extend([lngLat.lng, lngLat.lat]);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 根据地图上的覆盖物自适应地图
|
|
46
|
+
export function setFitView(map) {
|
|
47
|
+
var padding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 50;
|
|
48
|
+
var bounds = new mapabcgl.LngLatBounds();
|
|
49
|
+
getAllMarkers(bounds);
|
|
50
|
+
var arr = getAllLineLayers(map);
|
|
51
|
+
var geoJsonDatas = [];
|
|
52
|
+
arr.forEach(function (layer) {
|
|
53
|
+
// 检查图层是否有源数据
|
|
54
|
+
var source = map.getSource(layer.source);
|
|
55
|
+
if (source) {
|
|
56
|
+
// 获取源数据
|
|
57
|
+
var data = source.serialize().data;
|
|
58
|
+
geoJsonDatas.push(data);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
geoJsonDatas.forEach(function (item) {
|
|
62
|
+
item.features.forEach(function (feature) {
|
|
63
|
+
if (feature.geometry.type === 'Polygon') {
|
|
64
|
+
feature.geometry.coordinates[0].forEach(function (coordinate) {
|
|
65
|
+
bounds.extend(coordinate);
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
feature.geometry.coordinates.forEach(function (coordinate) {
|
|
69
|
+
bounds.extend(coordinate);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
if (isEmpty(bounds)) return;
|
|
75
|
+
if (typeof padding === 'number') {
|
|
76
|
+
map.fitBounds(bounds, {
|
|
77
|
+
padding: {
|
|
78
|
+
top: padding,
|
|
79
|
+
right: padding,
|
|
80
|
+
bottom: padding,
|
|
81
|
+
left: padding
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
map.fitBounds(bounds, {
|
|
86
|
+
padding: padding
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 根据地图上marker自适应地图
|
|
92
|
+
export function setFitViewByMarker(map) {
|
|
93
|
+
var padding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 50;
|
|
94
|
+
var markerId = arguments.length > 2 ? arguments[2] : undefined;
|
|
95
|
+
var bounds = new mapabcgl.LngLatBounds();
|
|
96
|
+
if (window.customMarkers) {
|
|
97
|
+
var keys = Object.keys(window.customMarkers);
|
|
98
|
+
|
|
99
|
+
// 假设 markers 是存储标记对象的数组
|
|
100
|
+
keys.forEach(function (key) {
|
|
101
|
+
if (Array.isArray(markerId)) {
|
|
102
|
+
if (markerId.includes(key)) {
|
|
103
|
+
var lngLat = window.customMarkers[key].getLngLat();
|
|
104
|
+
bounds.extend([lngLat.lng, lngLat.lat]);
|
|
105
|
+
bounds.extend([lngLat.lng + 0.01, lngLat.lat]);
|
|
106
|
+
bounds.extend([lngLat.lng - 0.01, lngLat.lat]);
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
if (key === markerId) {
|
|
110
|
+
var _lngLat = window.customMarkers[key].getLngLat();
|
|
111
|
+
bounds.extend([_lngLat.lng, _lngLat.lat]);
|
|
112
|
+
bounds.extend([_lngLat.lng + 0.01, _lngLat.lat]);
|
|
113
|
+
bounds.extend([_lngLat.lng - 0.01, _lngLat.lat]);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (isEmpty(bounds)) return;
|
|
119
|
+
if (typeof padding === 'number') {
|
|
120
|
+
map.fitBounds(bounds, {
|
|
121
|
+
padding: {
|
|
122
|
+
top: padding,
|
|
123
|
+
right: padding,
|
|
124
|
+
bottom: padding,
|
|
125
|
+
left: padding
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
} else {
|
|
129
|
+
map.fitBounds(bounds, {
|
|
130
|
+
padding: padding
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// 根据地图上polyline/polygon自适应地图
|
|
136
|
+
export function setFitViewByPolylineOrPolygon(map) {
|
|
137
|
+
var padding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 50;
|
|
138
|
+
var layerIds = arguments.length > 2 ? arguments[2] : undefined;
|
|
139
|
+
var bounds = new mapabcgl.LngLatBounds();
|
|
140
|
+
var arr = getTargetLayers(map, layerIds);
|
|
141
|
+
var geoJsonDatas = [];
|
|
142
|
+
arr.forEach(function (layer) {
|
|
143
|
+
// 检查图层是否有源数据
|
|
144
|
+
var source = map.getSource(layer.source);
|
|
145
|
+
if (source) {
|
|
146
|
+
// 获取源数据
|
|
147
|
+
var data = source.serialize().data;
|
|
148
|
+
geoJsonDatas.push(data);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
geoJsonDatas.forEach(function (item) {
|
|
152
|
+
item.features.forEach(function (feature) {
|
|
153
|
+
if (feature.geometry.type === 'Polygon') {
|
|
154
|
+
feature.geometry.coordinates[0].forEach(function (coordinate) {
|
|
155
|
+
bounds.extend(coordinate);
|
|
156
|
+
});
|
|
157
|
+
} else {
|
|
158
|
+
feature.geometry.coordinates.forEach(function (coordinate) {
|
|
159
|
+
bounds.extend(coordinate);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
if (isEmpty(bounds)) return;
|
|
165
|
+
if (typeof padding === 'number') {
|
|
166
|
+
map.fitBounds(bounds, {
|
|
167
|
+
padding: {
|
|
168
|
+
top: padding,
|
|
169
|
+
right: padding,
|
|
170
|
+
bottom: padding,
|
|
171
|
+
left: padding
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
} else {
|
|
175
|
+
map.fitBounds(bounds, {
|
|
176
|
+
padding: padding
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// mapabcgl
|
|
182
|
+
|
|
183
|
+
// 路径规划
|
|
184
|
+
export var getAutoLinePos = function getAutoLinePos(map, options) {
|
|
185
|
+
return new Promise(function (resolve, reject) {
|
|
186
|
+
map.Driving(options, function (res) {
|
|
187
|
+
if (Number(res.status) === 0) {
|
|
188
|
+
var steps = res.result.routes[0].steps;
|
|
189
|
+
var arr = [];
|
|
190
|
+
steps.forEach(function (item) {
|
|
191
|
+
var _wellknown$parse;
|
|
192
|
+
var text = item.path.replaceAll(',', ' ').replaceAll(';', ',');
|
|
193
|
+
text = "LINESTRING(".concat(text, ")");
|
|
194
|
+
// @ts-ignore
|
|
195
|
+
var coordinates = ((_wellknown$parse = wellknown.parse(text)) === null || _wellknown$parse === void 0 ? void 0 : _wellknown$parse.coordinates) || [];
|
|
196
|
+
arr = arr.concat(coordinates);
|
|
197
|
+
});
|
|
198
|
+
resolve(arr);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
// 处理区域数据 没有圈层 渲染 geoBig
|
|
205
|
+
export var transformAreaData = function transformAreaData(data) {
|
|
206
|
+
if (!isEmpty(data === null || data === void 0 ? void 0 : data.circleLayerList)) {
|
|
207
|
+
return data === null || data === void 0 ? void 0 : data.circleLayerList;
|
|
208
|
+
} else {
|
|
209
|
+
return [{
|
|
210
|
+
layerType: 'evacuation',
|
|
211
|
+
layerId: data === null || data === void 0 ? void 0 : data.geoBigAreaCode,
|
|
212
|
+
boundaryCoordinates: data === null || data === void 0 ? void 0 : data.geoBig
|
|
213
|
+
}];
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// 校验数组坐标范围是否合法
|
|
218
|
+
export var isValidLngLat = function isValidLngLat(data) {
|
|
219
|
+
if (!data) return false;
|
|
220
|
+
var flag = true;
|
|
221
|
+
data.forEach(function (item) {
|
|
222
|
+
if (isEmpty(item)) {
|
|
223
|
+
flag = false;
|
|
224
|
+
}
|
|
225
|
+
// 经度范围:-180 到 180
|
|
226
|
+
var lng = item[0];
|
|
227
|
+
var lat = item[1];
|
|
228
|
+
if (lng < -180 || lng > 180) {
|
|
229
|
+
flag = false;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// 纬度范围:-90 到 90
|
|
233
|
+
if (lat < -90 || lat > 90) {
|
|
234
|
+
flag = false;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
return flag;
|
|
238
|
+
};
|
|
239
|
+
export var deepClone = function deepClone(obj) {
|
|
240
|
+
return cloneDeepWith(obj, function (value) {
|
|
241
|
+
if (value === undefined) {
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
export var getBase64FromLocalImage = /*#__PURE__*/function () {
|
|
247
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
|
|
248
|
+
var response, blob, reader;
|
|
249
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
250
|
+
while (1) switch (_context.prev = _context.next) {
|
|
251
|
+
case 0:
|
|
252
|
+
_context.next = 2;
|
|
253
|
+
return fetch(url);
|
|
254
|
+
case 2:
|
|
255
|
+
response = _context.sent;
|
|
256
|
+
_context.next = 5;
|
|
257
|
+
return response.blob();
|
|
258
|
+
case 5:
|
|
259
|
+
blob = _context.sent;
|
|
260
|
+
reader = new FileReader();
|
|
261
|
+
reader.readAsDataURL(blob);
|
|
262
|
+
return _context.abrupt("return", new Promise(function (resolve) {
|
|
263
|
+
reader.onloadend = function () {
|
|
264
|
+
resolve(reader.result);
|
|
265
|
+
};
|
|
266
|
+
}));
|
|
267
|
+
case 9:
|
|
268
|
+
case "end":
|
|
269
|
+
return _context.stop();
|
|
270
|
+
}
|
|
271
|
+
}, _callee);
|
|
272
|
+
}));
|
|
273
|
+
return function getBase64FromLocalImage(_x) {
|
|
274
|
+
return _ref.apply(this, arguments);
|
|
275
|
+
};
|
|
276
|
+
}();
|
|
@@ -13,11 +13,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
13
13
|
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; }
|
|
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
|
-
import React, { useContext, useState, useMemo } from 'react';
|
|
17
|
-
import { message, Button } from 'antd';
|
|
18
16
|
import { Form, FormItem, Input, Select } from '@formily/antd-v5';
|
|
19
17
|
import { createForm } from '@formily/core';
|
|
20
18
|
import { createSchemaField } from '@formily/react';
|
|
19
|
+
import { Button, message } from 'antd';
|
|
20
|
+
import React, { useContext, useMemo, useState } from 'react';
|
|
21
21
|
import { hashWithCryptoJS, sm4Encrypt } from "../utils";
|
|
22
22
|
import ValueContext from "../context";
|
|
23
23
|
var SchemaField = createSchemaField({
|
|
@@ -202,13 +202,25 @@ var Index = function Index() {
|
|
|
202
202
|
return createForm({});
|
|
203
203
|
}, []);
|
|
204
204
|
return /*#__PURE__*/React.createElement("div", {
|
|
205
|
-
|
|
205
|
+
style: {
|
|
206
|
+
padding: 20
|
|
207
|
+
}
|
|
206
208
|
}, /*#__PURE__*/React.createElement("div", {
|
|
207
|
-
|
|
209
|
+
style: {
|
|
210
|
+
color: '#f00',
|
|
211
|
+
fontSize: 20,
|
|
212
|
+
marginBottom: 20
|
|
213
|
+
}
|
|
208
214
|
}, "\u521B\u5EFA\u8D85\u7BA1"), /*#__PURE__*/React.createElement("div", {
|
|
209
|
-
|
|
215
|
+
style: {
|
|
216
|
+
color: '#f00',
|
|
217
|
+
fontSize: 20,
|
|
218
|
+
marginBottom: 20
|
|
219
|
+
}
|
|
210
220
|
}, "\u8BE5\u529F\u80FD\u8BF7\u8C28\u614E\u64CD\u4F5C\uFF0C\u975E\u5FC5\u8981\u4E0D\u53EF\u64CD\u4F5C\uFF0C\u64CD\u4F5C\u524D\u9700\u8BE2\u95EE\u5F00\u53D1\u3002"), /*#__PURE__*/React.createElement("div", {
|
|
211
|
-
|
|
221
|
+
style: {
|
|
222
|
+
width: 400
|
|
223
|
+
}
|
|
212
224
|
}, /*#__PURE__*/React.createElement(Form, {
|
|
213
225
|
form: form,
|
|
214
226
|
labelWidth: 100
|
|
@@ -218,7 +230,9 @@ var Index = function Index() {
|
|
|
218
230
|
passwordConfig: passwordConfig
|
|
219
231
|
}
|
|
220
232
|
})), /*#__PURE__*/React.createElement("div", {
|
|
221
|
-
|
|
233
|
+
style: {
|
|
234
|
+
paddingLeft: 100
|
|
235
|
+
}
|
|
222
236
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
223
237
|
type: "primary",
|
|
224
238
|
onClick: handleOk,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepinnet-components/pc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.42",
|
|
4
4
|
"description": "A react library developed with dumi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -60,7 +60,8 @@
|
|
|
60
60
|
"lodash-es": "^4.17.21",
|
|
61
61
|
"md5": "^2.3.0",
|
|
62
62
|
"react-router-dom": "^7.6.2",
|
|
63
|
-
"shortid": "^2.2.17"
|
|
63
|
+
"shortid": "^2.2.17",
|
|
64
|
+
"wellknown": "^0.5.0"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
67
|
"@commitlint/cli": "^17.6.7",
|
|
@@ -68,6 +69,7 @@
|
|
|
68
69
|
"@types/lodash-es": "^4.17.8",
|
|
69
70
|
"@types/react": "^18.2.19",
|
|
70
71
|
"@types/react-dom": "^18.2.7",
|
|
72
|
+
"@types/wellknown": "^0.5.8",
|
|
71
73
|
"@umijs/lint": "^4.0.74",
|
|
72
74
|
"dumi": "^2.2.4",
|
|
73
75
|
"eslint": "^8.46.0",
|