@cloud-app-dev/vidc 3.0.19 → 3.0.21
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/es/Map/AMap.d.ts +4 -0
- package/es/Map/ClusterLayer/index.js +1 -1
- package/es/Map/MapDrawSelect/demo.d.ts +2 -0
- package/es/Map/MapDrawSelect/demo.js +58 -0
- package/es/Map/MapDrawSelect/index.css +0 -0
- package/es/Map/MapDrawSelect/index.d.ts +14 -0
- package/es/Map/MapDrawSelect/index.js +49 -0
- package/es/Map/MouseTool/index.d.ts +10 -0
- package/es/Map/MouseTool/index.js +50 -0
- package/es/Map/MouseTool/useMouseTools.d.ts +7 -0
- package/es/Map/MouseTool/useMouseTools.js +63 -0
- package/es/Map/interface.d.ts +2 -0
- package/es/ScreenPlayer/index.css +2 -2
- package/package.json +1 -1
package/es/Map/AMap.d.ts
CHANGED
|
@@ -6914,6 +6914,10 @@ declare global {
|
|
|
6914
6914
|
static post(path: string, params: any, callback: (status: string, data: any) => void): void;
|
|
6915
6915
|
}
|
|
6916
6916
|
|
|
6917
|
+
export class MouseTool {
|
|
6918
|
+
constructor(map: AMap.Map);
|
|
6919
|
+
}
|
|
6920
|
+
|
|
6917
6921
|
/**
|
|
6918
6922
|
* 图块切片加载完成事件
|
|
6919
6923
|
* @event complete
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
3
|
+
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."); }
|
|
4
|
+
|
|
5
|
+
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); }
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
+
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
13
|
+
import React, { useState } from 'react';
|
|
14
|
+
import MapDrawSelect from './index';
|
|
15
|
+
import deviceList from '../points.json';
|
|
16
|
+
|
|
17
|
+
var App = function App() {
|
|
18
|
+
var _useState = useState(),
|
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20
|
+
type = _useState2[0],
|
|
21
|
+
setType = _useState2[1];
|
|
22
|
+
|
|
23
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
style: {
|
|
25
|
+
width: '100%',
|
|
26
|
+
height: 800
|
|
27
|
+
}
|
|
28
|
+
}, /*#__PURE__*/React.createElement(MapDrawSelect, {
|
|
29
|
+
points: deviceList,
|
|
30
|
+
drawEnd: console.log,
|
|
31
|
+
drawType: type,
|
|
32
|
+
drawUi: /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
style: {
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
right: 20,
|
|
36
|
+
top: 120
|
|
37
|
+
}
|
|
38
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
39
|
+
onClick: function onClick() {
|
|
40
|
+
return setType(type === 'rect' ? 'close' : 'rect');
|
|
41
|
+
}
|
|
42
|
+
}, "\u77E9\u5F62"), /*#__PURE__*/React.createElement("span", {
|
|
43
|
+
onClick: function onClick() {
|
|
44
|
+
return setType(type === 'polygon' ? 'close' : 'polygon');
|
|
45
|
+
}
|
|
46
|
+
}, "\u591A\u8FB9\u5F62"), /*#__PURE__*/React.createElement("span", {
|
|
47
|
+
onClick: function onClick() {
|
|
48
|
+
return setType(type === 'circle' ? 'close' : 'circle');
|
|
49
|
+
}
|
|
50
|
+
}, "\u5706\u5F27"), /*#__PURE__*/React.createElement("span", {
|
|
51
|
+
onClick: function onClick() {
|
|
52
|
+
return setType('clear');
|
|
53
|
+
}
|
|
54
|
+
}, "\u6E05\u9664"))
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default App;
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DrawType, MapPoint } from '../interface';
|
|
3
|
+
import './index.less';
|
|
4
|
+
export interface IMapDrawSelectProps {
|
|
5
|
+
center?: [number, number];
|
|
6
|
+
zoom?: number;
|
|
7
|
+
points: MapPoint[];
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
drawUi?: React.ReactNode;
|
|
10
|
+
drawType?: DrawType | 'clear' | 'close';
|
|
11
|
+
drawEnd?: (points: MapPoint[]) => void;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: (props: IMapDrawSelectProps) => JSX.Element;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import _useMount from "ahooks/es/useMount";
|
|
2
|
+
import React, { useCallback, useContext, useMemo } from 'react';
|
|
3
|
+
import ClusterLayer from '../ClusterLayer';
|
|
4
|
+
import ResetTools from '../ResetTools';
|
|
5
|
+
import withMap from '../withMap';
|
|
6
|
+
import { mapContext } from '../Context';
|
|
7
|
+
import MouseTool from '../MouseTool';
|
|
8
|
+
import "./index.css";
|
|
9
|
+
|
|
10
|
+
function MapDrawSelect(_ref) {
|
|
11
|
+
var center = _ref.center,
|
|
12
|
+
zoom = _ref.zoom,
|
|
13
|
+
points = _ref.points,
|
|
14
|
+
children = _ref.children,
|
|
15
|
+
drawUi = _ref.drawUi,
|
|
16
|
+
drawType = _ref.drawType,
|
|
17
|
+
drawEnd = _ref.drawEnd;
|
|
18
|
+
|
|
19
|
+
var _useContext = useContext(mapContext),
|
|
20
|
+
instance = _useContext.instance;
|
|
21
|
+
|
|
22
|
+
var defaultCenter = useMemo(function () {
|
|
23
|
+
return center || instance.config.center;
|
|
24
|
+
}, [center, instance]);
|
|
25
|
+
var defaultZoom = useMemo(function () {
|
|
26
|
+
return zoom || instance.config.zoom;
|
|
27
|
+
}, [zoom, instance]); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
+
|
|
29
|
+
var mapRest = useCallback(function () {
|
|
30
|
+
return instance.setZoomAndCenter(defaultZoom, defaultCenter);
|
|
31
|
+
}, [defaultZoom, defaultCenter]);
|
|
32
|
+
|
|
33
|
+
_useMount(function () {
|
|
34
|
+
return mapRest();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ClusterLayer, {
|
|
38
|
+
points: points
|
|
39
|
+
}), /*#__PURE__*/React.createElement(ResetTools, {
|
|
40
|
+
onMapReset: mapRest
|
|
41
|
+
}), /*#__PURE__*/React.createElement(MouseTool, {
|
|
42
|
+
ui: drawUi,
|
|
43
|
+
drawType: drawType,
|
|
44
|
+
drawEnd: drawEnd,
|
|
45
|
+
points: points
|
|
46
|
+
}), children);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default withMap(MapDrawSelect, 'map-draw-select-container');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DrawType, MapPoint } from '../interface';
|
|
3
|
+
interface IMouseTool {
|
|
4
|
+
ui: React.ReactNode;
|
|
5
|
+
drawType?: DrawType | 'clear' | 'close';
|
|
6
|
+
drawEnd?: (points: MapPoint[]) => void;
|
|
7
|
+
points?: MapPoint[];
|
|
8
|
+
}
|
|
9
|
+
declare function MouseTool({ ui, drawType, points, drawEnd }: IMouseTool): JSX.Element;
|
|
10
|
+
export default MouseTool;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _useUpdateEffect from "ahooks/es/useUpdateEffect";
|
|
2
|
+
import _nextTick from "@cloud-app-dev/utils/es/nextTick";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import useMouseTools from './useMouseTools';
|
|
5
|
+
|
|
6
|
+
function MouseTool(_ref) {
|
|
7
|
+
var ui = _ref.ui,
|
|
8
|
+
drawType = _ref.drawType,
|
|
9
|
+
_ref$points = _ref.points,
|
|
10
|
+
points = _ref$points === void 0 ? [] : _ref$points,
|
|
11
|
+
drawEnd = _ref.drawEnd;
|
|
12
|
+
|
|
13
|
+
var _useMouseTools = useMouseTools(function (obj) {
|
|
14
|
+
var selectPoints = [];
|
|
15
|
+
|
|
16
|
+
for (var i = 0; i < points.length; i++) {
|
|
17
|
+
var item = points[i];
|
|
18
|
+
|
|
19
|
+
if (item.longitude && item.latitude && obj.contains([item.longitude, item.latitude])) {
|
|
20
|
+
selectPoints.push(item);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_nextTick(function () {
|
|
25
|
+
return drawEnd === null || drawEnd === void 0 ? void 0 : drawEnd(selectPoints);
|
|
26
|
+
});
|
|
27
|
+
}),
|
|
28
|
+
draw = _useMouseTools.draw,
|
|
29
|
+
close = _useMouseTools.close;
|
|
30
|
+
|
|
31
|
+
_useUpdateEffect(function () {
|
|
32
|
+
switch (drawType) {
|
|
33
|
+
case 'clear':
|
|
34
|
+
close(true);
|
|
35
|
+
break;
|
|
36
|
+
|
|
37
|
+
case 'close':
|
|
38
|
+
close();
|
|
39
|
+
break;
|
|
40
|
+
|
|
41
|
+
default:
|
|
42
|
+
draw(drawType);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}, [drawType]);
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, ui);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default MouseTool;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import _useMount from "ahooks/es/useMount";
|
|
2
|
+
import { useContext, useRef } from 'react';
|
|
3
|
+
import { mapContext } from '../Context';
|
|
4
|
+
|
|
5
|
+
function useMouseTools(onDrawEnd) {
|
|
6
|
+
var _useContext = useContext(mapContext),
|
|
7
|
+
instance = _useContext.instance;
|
|
8
|
+
|
|
9
|
+
var overlayersRef = useRef([]);
|
|
10
|
+
var mouseRef = useRef(null);
|
|
11
|
+
|
|
12
|
+
_useMount(function () {
|
|
13
|
+
var map = instance.map;
|
|
14
|
+
AMap.plugin(['AMap.MouseTool'], function () {
|
|
15
|
+
mouseRef.current = new AMap.MouseTool(map);
|
|
16
|
+
mouseRef.current.on('draw', function (e) {
|
|
17
|
+
overlayersRef.current.push(e.obj);
|
|
18
|
+
onDrawEnd === null || onDrawEnd === void 0 ? void 0 : onDrawEnd(e.obj);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
var draw = function draw(type) {
|
|
24
|
+
if (!mouseRef.current) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
switch (type) {
|
|
29
|
+
case 'rect':
|
|
30
|
+
mouseRef.current.rectangle();
|
|
31
|
+
break;
|
|
32
|
+
|
|
33
|
+
case 'polygon':
|
|
34
|
+
mouseRef.current.polygon();
|
|
35
|
+
break;
|
|
36
|
+
|
|
37
|
+
case 'circle':
|
|
38
|
+
mouseRef.current.circle();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var clear = function clear(objs) {
|
|
43
|
+
objs.forEach(function (obj) {
|
|
44
|
+
instance.map.remove(obj);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
var close = function close(ifClear) {
|
|
49
|
+
if (!mouseRef.current) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
mouseRef.current.close(ifClear);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
clear: clear,
|
|
58
|
+
draw: draw,
|
|
59
|
+
close: close
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default useMouseTools;
|
package/es/Map/interface.d.ts
CHANGED
|
@@ -139,8 +139,8 @@
|
|
|
139
139
|
color: var(--gray1);
|
|
140
140
|
}
|
|
141
141
|
.cloudapp-select.time-mode-select .cloudapp-select-selector {
|
|
142
|
-
background-color: transparent;
|
|
143
|
-
border-radius: var(--radius1);
|
|
142
|
+
background-color: transparent !important;
|
|
143
|
+
border-radius: var(--radius1) !important;
|
|
144
144
|
}
|
|
145
145
|
.cloudapp-select.time-mode-select .anticon {
|
|
146
146
|
color: var(--gray1);
|