@cloud-app-dev/vidc 3.2.11 → 3.2.14
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/.dumirc.ts +71 -0
- package/.editorconfig +0 -3
- package/.eslintrc.js +3 -0
- package/.fatherrc.ts +19 -0
- package/.husky/commit-msg +5 -0
- package/.husky/pre-commit +4 -0
- package/.prettierrc.js +16 -0
- package/README.md +14 -26
- package/es/Api/index.js +100 -30
- package/es/AppContext/Sync.js +19 -3
- package/es/AppContext/index.js +86 -42
- package/es/AppContext/static.js +7 -0
- package/es/Auth/index.js +11 -4
- package/es/AutoExit/index.js +11 -3
- package/es/Box/BetweenBox/index.js +19 -10
- package/es/Box/BetweenBox/{index.css → index.less} +0 -0
- package/es/Box/InfoBox/index.js +24 -18
- package/es/Box/InfoBox/index.less +22 -0
- package/es/Box/TwoColumnBox/index.js +42 -25
- package/es/Box/TwoColumnBox/index.less +70 -0
- package/es/Box/deps/grid-factory.d.ts +2 -2
- package/es/Box/deps/grid-factory.js +12 -0
- package/es/Box/index.js +29 -16
- package/es/Box/{index.css → index.less} +5 -4
- package/es/CheckGroupFixed/demo.d.ts +3 -0
- package/es/CheckGroupFixed/demo.js +28 -0
- package/es/CheckGroupFixed/index.js +117 -82
- package/es/CheckGroupFixed/index.less +50 -0
- package/es/Config/index.js +5 -1
- package/es/Config/utils.js +18 -3
- package/es/ConfigContext/index.js +8 -4
- package/es/CustomRenderSelect/index.js +71 -36
- package/es/CustomRenderSelect/index.less +25 -0
- package/es/DisableMark/index.js +14 -11
- package/es/DisableMark/{index.css → index.less} +0 -0
- package/es/DomMove/demo.js +14 -10
- package/es/DomMove/index.js +52 -30
- package/es/DomMove/utils.js +8 -3
- package/es/Drag/DragAndDropItem.js +44 -20
- package/es/Drag/DropItem.js +22 -6
- package/es/Drag/index.js +2 -2
- package/es/Drag/{index.css → index.less} +0 -0
- package/es/Drawer/Footer.js +22 -15
- package/es/Drawer/{Demo.d.ts → demo.d.ts} +0 -0
- package/es/Drawer/demo.js +109 -0
- package/es/Drawer/index.js +98 -60
- package/es/Drawer/index.less +42 -0
- package/es/ErrorFallback/index.js +23 -14
- package/es/FrontendPlayer/index.js +1 -1
- package/es/FullScreen/index.js +30 -17
- package/es/FullScreen/index.less +16 -0
- package/es/HightLevel/index.js +11 -4
- package/es/HightLevel/{index.css → index.less} +0 -0
- package/es/IconFont/index.js +39 -18
- package/es/ImageView/index.js +37 -13
- package/es/ImageView/index.less +10 -0
- package/es/Input/demo.d.ts +3 -0
- package/es/Input/demo.js +16 -0
- package/es/Input/index.js +46 -22
- package/es/Input/index.less +12 -0
- package/es/InstanceHistory/index.js +2 -0
- package/es/LabelValue/index.js +25 -18
- package/es/LabelValue/index.less +20 -0
- package/es/List/DynamicGridList/Demo.d.ts +1 -0
- package/es/List/DynamicGridList/Demo.js +52 -32
- package/es/List/DynamicGridList/index.d.ts +3 -3
- package/es/List/DynamicGridList/index.js +41 -26
- package/es/List/DynamicList/index.js +76 -56
- package/es/List/DynamicList/index.less +15 -0
- package/es/List/GridList/Demo.d.ts +1 -0
- package/es/List/GridList/Demo.js +60 -38
- package/es/List/GridList/hook.d.ts +1 -1
- package/es/List/GridList/hook.js +66 -35
- package/es/List/GridList/index.js +33 -29
- package/es/List/GridList/{index.css → index.less} +0 -0
- package/es/List/GridList/utils.d.ts +2 -2
- package/es/List/GridList/utils.js +1 -0
- package/es/List/VList/index.d.ts +1 -1
- package/es/List/VList/index.js +32 -19
- package/es/List/VList/{index.css → index.less} +0 -0
- package/es/List/VList/utils.d.ts +2 -2
- package/es/List/VList/utils.js +8 -6
- package/es/List/demo.d.ts +3 -0
- package/es/List/demo.js +26 -0
- package/es/List/index.d.ts +1 -1
- package/es/List/index.js +31 -23
- package/es/List/{index.css → index.less} +5 -4
- package/es/ListWithSizeAnimate/demo.d.ts +2 -0
- package/es/ListWithSizeAnimate/demo.js +19 -0
- package/es/ListWithSizeAnimate/index.d.ts +9 -0
- package/es/ListWithSizeAnimate/index.js +71 -0
- package/es/ListWithSizeAnimate/index.less +13 -0
- package/es/LoaderApp/index.js +59 -25
- package/es/LoaderApp/{index.css → index.less} +0 -0
- package/es/LoaderApp/loader.js +40 -23
- package/es/LoaderApp/sandbox.back.js +101 -24
- package/es/LoaderApp/sandbox.js +26 -9
- package/es/LoaderApp/utils.d.ts +1 -1
- package/es/LoaderApp/utils.js +68 -25
- package/es/LoaderScript/index.js +25 -10
- package/es/LoaderScript/utils.js +151 -87
- package/es/Map/BasicMap/AMapInstance.d.ts +1 -1
- package/es/Map/BasicMap/AMapInstance.js +25 -3
- package/es/Map/BasicMap/LeafletInstance.js +28 -11
- package/es/Map/BasicMap/index.js +67 -27
- package/es/Map/BasicMap/index.less +24 -0
- package/es/Map/ClusterLayer/hook.d.ts +2 -2
- package/es/Map/ClusterLayer/hook.js +51 -23
- package/es/Map/ClusterLayer/index.d.ts +1 -1
- package/es/Map/ClusterLayer/index.js +14 -6
- package/es/Map/ClusterLayer/index.less +27 -0
- package/es/Map/Config/index.js +44 -16
- package/es/Map/Config/utils.js +17 -3
- package/es/Map/Context/index.js +43 -9
- package/es/Map/FindPio/index.js +5 -2
- package/es/Map/FindPio/{index.css → index.less} +0 -0
- package/es/Map/InfoWindow/MakerLikeWindow.d.ts +1 -1
- package/es/Map/InfoWindow/MakerLikeWindow.js +41 -18
- package/es/Map/InfoWindow/demo.d.ts +1 -0
- package/es/Map/InfoWindow/demo.js +51 -29
- package/es/Map/InfoWindow/index.d.ts +1 -1
- package/es/Map/InfoWindow/index.js +39 -18
- package/es/Map/LevelCenter/DragMarker/index.js +16 -10
- package/es/Map/LevelCenter/demo.d.ts +1 -0
- package/es/Map/LevelCenter/demo.js +41 -22
- package/es/Map/LevelCenter/index.js +41 -29
- package/es/Map/LevelCenter/index.less +2 -0
- package/es/Map/LoaderMap/index.js +38 -22
- package/es/Map/MapDrawSelect/demo.d.ts +1 -0
- package/es/Map/MapDrawSelect/demo.js +65 -46
- package/es/Map/MapDrawSelect/index.js +43 -31
- package/es/Map/MapDrawSelect/index.less +2 -0
- package/es/Map/MouseTool/index.js +32 -18
- package/es/Map/MouseTool/useMouseTools.js +37 -8
- package/es/Map/ResetTools/index.js +58 -44
- package/es/Map/ResetTools/index.less +35 -0
- package/es/Map/SinglePoint/index.js +39 -27
- package/es/Map/SinglePoint/index.less +41 -0
- package/es/Map/hook/useMapEvent.js +8 -4
- package/es/Map/hook/useMapType.js +3 -2
- package/es/Map/index.d.ts +1 -0
- package/es/Map/index.js +11 -11
- package/es/Map/useMarker/index.d.ts +1 -1
- package/es/Map/useMarker/index.js +33 -13
- package/es/Map/{LevelCenter/index.css → useMarker/index.less} +0 -0
- package/es/Map/withMap/index.d.ts +1 -0
- package/es/Map/withMap/index.js +14 -4
- package/es/Modal/demo.d.ts +3 -0
- package/es/Modal/demo.js +106 -0
- package/es/Modal/index.js +94 -57
- package/es/Modal/index.less +45 -0
- package/es/Picture/component/DefaultRects/RectInfo.js +59 -37
- package/es/Picture/component/DefaultRects/index.js +46 -32
- package/es/Picture/component/DefaultRects/index.less +188 -0
- package/es/Picture/component/DrawRect/index.js +37 -24
- package/es/Picture/component/DrawRect/{index.css → index.less} +0 -0
- package/es/Picture/component/RectMenu/index.js +35 -26
- package/es/Picture/component/RectMenu/index.less +31 -0
- package/es/Picture/component/RectMenu/utils.js +6 -3
- package/es/Picture/component/Tools/index.js +91 -69
- package/es/Picture/component/Tools/index.less +43 -0
- package/es/Picture/component/WheelScale/index.js +9 -4
- package/es/Picture/demo.js +14 -11
- package/es/Picture/dragBound.d.ts +1 -1
- package/es/Picture/dragBound.js +17 -4
- package/es/Picture/index.d.ts +2 -2
- package/es/Picture/index.js +201 -137
- package/es/Picture/index.less +14 -0
- package/es/Picture/interface.d.ts +0 -6
- package/es/Picture/loadCaptureRectImage.d.ts +1 -1
- package/es/Picture/loadCaptureRectImage.js +39 -14
- package/es/Picture/useDraw.js +40 -20
- package/es/Picture/utils.d.ts +9 -9
- package/es/Picture/utils.js +18 -3
- package/es/Player/api/index.d.ts +3 -3
- package/es/Player/api/index.js +117 -82
- package/es/Player/context.js +21 -7
- package/es/Player/contraller_bar/bar.d.ts +1 -1
- package/es/Player/contraller_bar/bar.js +28 -10
- package/es/Player/contraller_bar/contraller_event.js +34 -12
- package/es/Player/contraller_bar/index.js +30 -22
- package/es/Player/contraller_bar/left_bar.js +62 -39
- package/es/Player/contraller_bar/right_bar.js +34 -18
- package/es/Player/contraller_bar/time.js +19 -8
- package/es/Player/contraller_bar/useBarStatus.js +29 -11
- package/es/Player/contraller_bar/volume.d.ts +1 -1
- package/es/Player/contraller_bar/volume.js +43 -21
- package/es/Player/demo.d.ts +1 -0
- package/es/Player/demo.js +258 -215
- package/es/Player/event/errorEvent.js +41 -16
- package/es/Player/event/eventName.js +12 -1
- package/es/Player/event/index.js +66 -24
- package/es/Player/fps_play.js +33 -15
- package/es/Player/frontend_player.js +42 -20
- package/es/Player/frontend_timeline.js +95 -55
- package/es/Player/iconfont.js +23 -8
- package/es/Player/index.js +1 -1
- package/es/Player/live_heart.js +15 -3
- package/es/Player/message.js +68 -37
- package/es/Player/segment_player.js +113 -62
- package/es/Player/segment_timeline.js +145 -97
- package/es/Player/single_player.js +153 -111
- package/es/Player/style/bar.less +39 -0
- package/es/Player/style/iconfont.js +17 -10
- package/es/Player/style/index.less +30 -0
- package/es/Player/style/message.less +50 -0
- package/es/Player/style/slider.less +103 -0
- package/es/Player/style/timeline.less +106 -0
- package/es/Player/style/volume.less +21 -0
- package/es/Player/timeline.d.ts +1 -1
- package/es/Player/timeline.js +59 -32
- package/es/Player/util.js +46 -7
- package/es/PlayerExt/demo.d.ts +1 -0
- package/es/PlayerExt/demo.js +145 -112
- package/es/PlayerExt/index.d.ts +2 -2
- package/es/PlayerExt/index.js +139 -87
- package/es/PlayerExt/{index.css → index.less} +0 -0
- package/es/Progress/index.js +18 -5
- package/es/Progress/index.less +20 -0
- package/es/ROI/demo.d.ts +1 -0
- package/es/ROI/demo.js +12 -8
- package/es/ROI/index.js +45 -35
- package/es/ROI/index.less +29 -0
- package/es/ScreenPlayer/Live.d.ts +2 -2
- package/es/ScreenPlayer/Live.js +172 -109
- package/es/ScreenPlayer/LiveTools.d.ts +2 -2
- package/es/ScreenPlayer/LiveTools.js +156 -116
- package/es/ScreenPlayer/PlayerWithExt.d.ts +2 -2
- package/es/ScreenPlayer/PlayerWithExt.js +172 -115
- package/es/ScreenPlayer/RatePick.js +35 -22
- package/es/ScreenPlayer/Record.d.ts +1 -1
- package/es/ScreenPlayer/Record.js +307 -192
- package/es/ScreenPlayer/RecordTools.d.ts +2 -2
- package/es/ScreenPlayer/RecordTools.js +201 -149
- package/es/ScreenPlayer/ScreenSelect.js +37 -28
- package/es/ScreenPlayer/SegmentTimeLine.d.ts +1 -1
- package/es/ScreenPlayer/SegmentTimeLine.js +24 -17
- package/es/ScreenPlayer/TimeMode.js +22 -16
- package/es/ScreenPlayer/TimeSelect.js +86 -65
- package/es/ScreenPlayer/demo.js +16 -18
- package/es/ScreenPlayer/demo2.js +193 -178
- package/es/ScreenPlayer/index.d.ts +1 -0
- package/es/ScreenPlayer/index.js +3 -3
- package/es/ScreenPlayer/index.less +178 -0
- package/es/ScreenPlayer/interface.d.ts +2 -2
- package/es/ScreenPlayer/useTimeSlider.d.ts +8 -8
- package/es/ScreenPlayer/useTimeSlider.js +167 -60
- package/es/ScreenPlayer/useVideoFit.d.ts +1 -1
- package/es/ScreenPlayer/useVideoFit.js +18 -5
- package/es/ScreenPlayer/utils.d.ts +1 -1
- package/es/ScreenPlayer/utils.js +10 -1
- package/es/SegmentPlayer/index.js +1 -1
- package/es/Service/fetch-adapter.d.ts +1 -1
- package/es/Service/fetch-adapter.js +48 -5
- package/es/Service/http.js +46 -16
- package/es/Service/index.js +2 -2
- package/es/TableLayout/index.js +18 -12
- package/es/TableLayout/{index.css → index.less} +0 -0
- package/es/ThemeAntd/demo.d.ts +1 -0
- package/es/ThemeAntd/demo.js +126 -76
- package/es/ThemeAntd/{demo.css → demo.less} +4 -3
- package/es/ThemeAntd/index.js +6 -2
- package/es/ThemeAntd/index.less +16 -0
- package/es/ThemeAntd/style/button.less +67 -0
- package/es/ThemeAntd/style/checkbox.less +72 -0
- package/es/ThemeAntd/style/form.less +12 -0
- package/es/ThemeAntd/style/input.less +83 -0
- package/es/ThemeAntd/style/pagination.less +95 -0
- package/es/ThemeAntd/style/picker.less +106 -0
- package/es/ThemeAntd/style/popover.less +5 -0
- package/es/ThemeAntd/style/radio.less +87 -0
- package/es/ThemeAntd/style/{scrollbar.css → scrollbar.less} +4 -2
- package/es/ThemeAntd/style/select.less +81 -0
- package/es/ThemeAntd/style/table.less +57 -0
- package/es/ThemeAntd/style/tree.less +18 -0
- package/es/Timeout/index.js +36 -12
- package/es/Tree/demo.js +26 -21
- package/es/Tree/index.js +51 -30
- package/es/Tree/index.less +59 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +48 -47
- package/es/useDrawROI/index.js +130 -65
- package/es/useEventEmitterHandle/index.js +6 -2
- package/es/useFullscreen/demo.js +44 -27
- package/es/useFullscreen/index.js +30 -8
- package/es/useHistory/index.js +3 -1
- package/es/useInfiniteScroll/index.js +50 -19
- package/es/useRafInterval/index.js +28 -4
- package/es/useSimpleState/index.js +23 -6
- package/es/useVirtualList/index.js +58 -20
- package/es/utils.d.ts +1 -1
- package/es/utils.js +53 -14
- package/package.json +37 -32
- package/tsconfig.json +8 -32
- package/.eslintrc +0 -4
- package/.fatherrc.js +0 -25
- package/.prettierrc +0 -11
- package/.umirc.ts +0 -55
- package/clear-cache.sh +0 -4
- package/es/Box/InfoBox/index.css +0 -22
- package/es/Box/TwoColumnBox/index.css +0 -70
- package/es/CheckGroupFixed/index.css +0 -49
- package/es/CustomRenderSelect/index.css +0 -20
- package/es/Drawer/Demo.js +0 -59
- package/es/Drawer/index.css +0 -40
- package/es/FullScreen/index.css +0 -16
- package/es/ImageView/index.css +0 -10
- package/es/Input/index.css +0 -8
- package/es/LabelValue/index.css +0 -18
- package/es/List/DynamicList/index.css +0 -15
- package/es/Map/BasicMap/index.css +0 -24
- package/es/Map/ClusterLayer/index.css +0 -26
- package/es/Map/MapDrawSelect/index.css +0 -0
- package/es/Map/ResetTools/index.css +0 -32
- package/es/Map/SinglePoint/icon/Place_icon_OnLine_Hover.svg +0 -15
- package/es/Map/SinglePoint/icon/Place_icon_OnLine_Normal.svg +0 -15
- package/es/Map/SinglePoint/icon/Place_icon_OutLine_Hover.svg +0 -15
- package/es/Map/SinglePoint/icon/Place_icon_OutLine_Normal.svg +0 -15
- package/es/Map/SinglePoint/index.css +0 -29
- package/es/Map/useMarker/index.css +0 -0
- package/es/Modal/index.css +0 -43
- package/es/Picture/component/DefaultRects/index.css +0 -247
- package/es/Picture/component/RectMenu/index.css +0 -31
- package/es/Picture/component/Tools/index.css +0 -42
- package/es/Picture/index.css +0 -12
- package/es/Player/style/bar.css +0 -38
- package/es/Player/style/index.css +0 -30
- package/es/Player/style/message.css +0 -49
- package/es/Player/style/slider.css +0 -96
- package/es/Player/style/timeline.css +0 -99
- package/es/Player/style/volume.css +0 -19
- package/es/Progress/index.css +0 -20
- package/es/ROI/index.css +0 -29
- package/es/ScreenPlayer/index.css +0 -166
- package/es/ThemeAntd/index.css +0 -620
- package/es/ThemeAntd/style/button.css +0 -55
- package/es/ThemeAntd/style/checkbox.css +0 -64
- package/es/ThemeAntd/style/form.css +0 -10
- package/es/ThemeAntd/style/input.css +0 -68
- package/es/ThemeAntd/style/pagination.css +0 -82
- package/es/ThemeAntd/style/picker.css +0 -98
- package/es/ThemeAntd/style/popover.css +0 -3
- package/es/ThemeAntd/style/radio.css +0 -80
- package/es/ThemeAntd/style/select.css +0 -76
- package/es/ThemeAntd/style/table.css +0 -46
- package/es/ThemeAntd/style/tree.css +0 -16
- package/es/Tree/index.css +0 -64
|
@@ -1,37 +1,46 @@
|
|
|
1
1
|
import _useMount from "ahooks/es/useMount";
|
|
2
2
|
import React, { useCallback, useContext, useMemo } from 'react';
|
|
3
|
-
import ClusterLayer from
|
|
4
|
-
import ResetTools from
|
|
5
|
-
import DragMarker from
|
|
6
|
-
import withMap from
|
|
7
|
-
import { mapContext } from
|
|
8
|
-
import useMapEvent from
|
|
9
|
-
import "./index.
|
|
3
|
+
import ClusterLayer from "../ClusterLayer";
|
|
4
|
+
import ResetTools from "../ResetTools";
|
|
5
|
+
import DragMarker from "./DragMarker";
|
|
6
|
+
import withMap from "../withMap";
|
|
7
|
+
import { mapContext } from "../Context";
|
|
8
|
+
import useMapEvent from "../hook/useMapEvent";
|
|
9
|
+
import "./index.less";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
|
|
10
14
|
function LevelCenter(_ref) {
|
|
11
15
|
var center = _ref.center,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
zoom = _ref.zoom,
|
|
17
|
+
points = _ref.points,
|
|
18
|
+
onLevelCenterChange = _ref.onLevelCenterChange,
|
|
19
|
+
enableClick = _ref.enableClick,
|
|
20
|
+
children = _ref.children;
|
|
21
|
+
|
|
17
22
|
var _useContext = useContext(mapContext),
|
|
18
|
-
|
|
23
|
+
instance = _useContext.instance;
|
|
24
|
+
|
|
19
25
|
var defaultCenter = useMemo(function () {
|
|
20
26
|
return center || instance.config.center;
|
|
21
27
|
}, [center, instance]);
|
|
22
28
|
var defaultZoom = useMemo(function () {
|
|
23
29
|
return zoom || instance.config.zoom;
|
|
24
|
-
}, [zoom, instance]);
|
|
25
|
-
|
|
30
|
+
}, [zoom, instance]); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
+
|
|
26
32
|
var mapRest = useCallback(function () {
|
|
27
33
|
return instance.setZoomAndCenter(defaultZoom, defaultCenter);
|
|
28
34
|
}, [defaultZoom, defaultCenter]);
|
|
35
|
+
|
|
29
36
|
_useMount(function () {
|
|
30
37
|
if (enableClick) {
|
|
31
38
|
instance.setCursor('pointer');
|
|
32
39
|
}
|
|
40
|
+
|
|
33
41
|
mapRest();
|
|
34
42
|
});
|
|
43
|
+
|
|
35
44
|
useMapEvent('click', function (event) {
|
|
36
45
|
if (enableClick) {
|
|
37
46
|
var _center = [event.lnglat.lng, event.lnglat.lat];
|
|
@@ -48,19 +57,22 @@ function LevelCenter(_ref) {
|
|
|
48
57
|
zoom: instance.getZoom()
|
|
49
58
|
});
|
|
50
59
|
});
|
|
51
|
-
return /*#__PURE__*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
61
|
+
children: [/*#__PURE__*/_jsx(ClusterLayer, {
|
|
62
|
+
points: points
|
|
63
|
+
}), /*#__PURE__*/_jsx(ResetTools, {
|
|
64
|
+
onMapReset: mapRest
|
|
65
|
+
}), /*#__PURE__*/_jsx(DragMarker, {
|
|
66
|
+
center: defaultCenter,
|
|
67
|
+
onChange: function onChange(_ref2) {
|
|
68
|
+
var center = _ref2.center;
|
|
69
|
+
return onLevelCenterChange === null || onLevelCenterChange === void 0 ? void 0 : onLevelCenterChange({
|
|
70
|
+
center: center,
|
|
71
|
+
zoom: instance.getZoom()
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}), children]
|
|
75
|
+
});
|
|
65
76
|
}
|
|
77
|
+
|
|
66
78
|
export default withMap(LevelCenter, 'lv-center-map-container');
|
|
@@ -1,35 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
var _excluded = ["children", "MAP_GLABAL_KEY"];
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
|
|
9
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
|
+
|
|
11
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
|
+
|
|
2
13
|
import React, { useMemo } from 'react';
|
|
3
|
-
import Config from
|
|
4
|
-
import LoaderScript from
|
|
14
|
+
import Config from "../../Config";
|
|
15
|
+
import LoaderScript from "../../LoaderScript";
|
|
16
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
18
|
var L_SCRIPTS = [{
|
|
6
19
|
scripts: ['https://cdn.bootcdn.net/ajax/libs/leaflet/1.8.0/leaflet.min.js'],
|
|
7
|
-
styles: ['https://cdn.bootcdn.net/ajax/libs/leaflet/1.8.0/leaflet.min.css']
|
|
8
|
-
// scripts: ['/statics/libs/map/leaflet/leaflet.min.js'],
|
|
20
|
+
styles: ['https://cdn.bootcdn.net/ajax/libs/leaflet/1.8.0/leaflet.min.css'] // scripts: ['/statics/libs/map/leaflet/leaflet.min.js'],
|
|
9
21
|
// styles: ['/statics/libs/map/leaflet/leaflet.min.css'],
|
|
22
|
+
|
|
10
23
|
}, {
|
|
11
|
-
scripts: ['https://cdn.bootcdn.net/ajax/libs/leaflet.markercluster/1.5.3/leaflet.markercluster.min.js'
|
|
12
|
-
// '/statics/libs/map/leaflet/echarts-leaflet.js'
|
|
24
|
+
scripts: ['https://cdn.bootcdn.net/ajax/libs/leaflet.markercluster/1.5.3/leaflet.markercluster.min.js' // '/statics/libs/map/leaflet/echarts-leaflet.js'
|
|
13
25
|
// '/statics/libs/map/leaflet/leaflet.markercluster.js'
|
|
14
26
|
],
|
|
15
|
-
|
|
16
|
-
styles: ['https://cdn.bootcdn.net/ajax/libs/leaflet.markercluster/1.5.3/MarkerCluster.min.css', 'https://cdn.bootcdn.net/ajax/libs/leaflet.markercluster/1.5.3/MarkerCluster.Default.min.css'
|
|
17
|
-
// '/statics/libs/map/leaflet/MarkerCluster.css'
|
|
27
|
+
styles: ['https://cdn.bootcdn.net/ajax/libs/leaflet.markercluster/1.5.3/MarkerCluster.min.css', 'https://cdn.bootcdn.net/ajax/libs/leaflet.markercluster/1.5.3/MarkerCluster.Default.min.css' // '/statics/libs/map/leaflet/MarkerCluster.css'
|
|
18
28
|
// '/statics/libs/map/leaflet/MarkerCluster.Default.css'
|
|
19
29
|
]
|
|
20
30
|
}];
|
|
21
|
-
|
|
22
31
|
var AMAP_SCRIPTS = [{
|
|
23
32
|
scripts: ['https://webapi.amap.com/maps?v=2.0&key=2232e46c0b578b711e6e9851cb92dbfe']
|
|
24
33
|
}];
|
|
34
|
+
|
|
25
35
|
function EmptyParent(_ref) {
|
|
26
36
|
var children = _ref.children;
|
|
27
|
-
return /*#__PURE__*/
|
|
37
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
38
|
+
children: children
|
|
39
|
+
});
|
|
28
40
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
|
|
42
|
+
function LoaderMap(_ref2) {
|
|
43
|
+
var children = _ref2.children,
|
|
44
|
+
MAP_GLABAL_KEY = _ref2.MAP_GLABAL_KEY,
|
|
45
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
46
|
+
|
|
33
47
|
var glaobalKey = useMemo(function () {
|
|
34
48
|
return MAP_GLABAL_KEY ? MAP_GLABAL_KEY : Config.BSConfig.MAP_GLABAL_KEY || 'L';
|
|
35
49
|
}, [MAP_GLABAL_KEY]);
|
|
@@ -45,13 +59,15 @@ function LoaderMap(_a) {
|
|
|
45
59
|
var Parent = useMemo(function () {
|
|
46
60
|
return isLoaded ? EmptyParent : LoaderScript;
|
|
47
61
|
}, [isLoaded]);
|
|
48
|
-
return /*#__PURE__*/
|
|
49
|
-
options: options
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
return /*#__PURE__*/_jsx(Parent, {
|
|
63
|
+
options: options,
|
|
64
|
+
children: /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, props), {}, {
|
|
65
|
+
isL: isL,
|
|
66
|
+
glaobalKey: glaobalKey
|
|
67
|
+
}))
|
|
68
|
+
});
|
|
54
69
|
}
|
|
70
|
+
|
|
55
71
|
LoaderMap.defaultProps = {
|
|
56
72
|
MAP_GLABAL_KEY: 'AMap'
|
|
57
73
|
};
|
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
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
|
+
|
|
3
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
|
+
|
|
4
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
|
+
|
|
5
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
|
+
|
|
6
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
7
13
|
import React, { useEffect, useState } from 'react';
|
|
8
|
-
import MapDrawSelect from
|
|
9
|
-
import deviceList from
|
|
14
|
+
import MapDrawSelect from "./index";
|
|
15
|
+
import deviceList from "../points.json";
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
|
|
10
19
|
var App = function App() {
|
|
11
20
|
var _useState = useState([]),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
points = _useState2[0],
|
|
23
|
+
setPoints = _useState2[1];
|
|
24
|
+
|
|
15
25
|
var _useState3 = useState(),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
27
|
+
type = _useState4[0],
|
|
28
|
+
setType = _useState4[1];
|
|
29
|
+
|
|
19
30
|
var _useState5 = useState({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
zoom: null,
|
|
32
|
+
center: null
|
|
33
|
+
}),
|
|
34
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
35
|
+
state = _useState6[0],
|
|
36
|
+
setState = _useState6[1];
|
|
37
|
+
|
|
26
38
|
useEffect(function () {
|
|
27
39
|
setTimeout(function () {
|
|
28
40
|
setPoints(deviceList);
|
|
@@ -32,40 +44,47 @@ var App = function App() {
|
|
|
32
44
|
});
|
|
33
45
|
}, 1000);
|
|
34
46
|
}, []);
|
|
35
|
-
return /*#__PURE__*/
|
|
47
|
+
return /*#__PURE__*/_jsx("div", {
|
|
36
48
|
style: {
|
|
37
49
|
width: '100%',
|
|
38
50
|
height: 800
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
51
|
+
},
|
|
52
|
+
children: /*#__PURE__*/_jsx(MapDrawSelect, {
|
|
53
|
+
zoom: state.zoom,
|
|
54
|
+
center: state.center,
|
|
55
|
+
points: points,
|
|
56
|
+
drawEnd: console.log,
|
|
57
|
+
drawType: type,
|
|
58
|
+
drawUi: /*#__PURE__*/_jsxs("div", {
|
|
59
|
+
style: {
|
|
60
|
+
position: 'absolute',
|
|
61
|
+
right: 20,
|
|
62
|
+
top: 120
|
|
63
|
+
},
|
|
64
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
65
|
+
onClick: function onClick() {
|
|
66
|
+
return setType(type === 'rect' ? 'close' : 'rect');
|
|
67
|
+
},
|
|
68
|
+
children: "\u77E9\u5F62"
|
|
69
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
70
|
+
onClick: function onClick() {
|
|
71
|
+
return setType(type === 'polygon' ? 'close' : 'polygon');
|
|
72
|
+
},
|
|
73
|
+
children: "\u591A\u8FB9\u5F62"
|
|
74
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
75
|
+
onClick: function onClick() {
|
|
76
|
+
return setType(type === 'circle' ? 'close' : 'circle');
|
|
77
|
+
},
|
|
78
|
+
children: "\u5706\u5F27"
|
|
79
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
80
|
+
onClick: function onClick() {
|
|
81
|
+
return setType('clear');
|
|
82
|
+
},
|
|
83
|
+
children: "\u6E05\u9664"
|
|
84
|
+
})]
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
});
|
|
70
88
|
};
|
|
89
|
+
|
|
71
90
|
export default App;
|
|
@@ -1,57 +1,69 @@
|
|
|
1
1
|
import _useUpdateEffect from "ahooks/es/useUpdateEffect";
|
|
2
2
|
import _useMount from "ahooks/es/useMount";
|
|
3
3
|
import React, { useCallback, useContext, useEffect, useMemo } from 'react';
|
|
4
|
-
import ClusterLayer from
|
|
5
|
-
import ResetTools from
|
|
6
|
-
import withMap from
|
|
7
|
-
import { mapContext } from
|
|
8
|
-
import MouseTool from
|
|
9
|
-
import "./index.
|
|
4
|
+
import ClusterLayer from "../ClusterLayer";
|
|
5
|
+
import ResetTools from "../ResetTools";
|
|
6
|
+
import withMap from "../withMap";
|
|
7
|
+
import { mapContext } from "../Context";
|
|
8
|
+
import MouseTool from "../MouseTool";
|
|
9
|
+
import "./index.less";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
|
|
10
14
|
function MapDrawSelect(_ref) {
|
|
11
15
|
var center = _ref.center,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
zoom = _ref.zoom,
|
|
17
|
+
points = _ref.points,
|
|
18
|
+
children = _ref.children,
|
|
19
|
+
drawUi = _ref.drawUi,
|
|
20
|
+
drawType = _ref.drawType,
|
|
21
|
+
selectCenter = _ref.selectCenter,
|
|
22
|
+
drawEnd = _ref.drawEnd,
|
|
23
|
+
onPointClick = _ref.onPointClick;
|
|
24
|
+
|
|
20
25
|
var _useContext = useContext(mapContext),
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
instance = _useContext.instance; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
|
+
|
|
28
|
+
|
|
23
29
|
var defaultCenter = useMemo(function () {
|
|
24
30
|
return center || instance.config.center;
|
|
25
|
-
}, [center]);
|
|
26
|
-
|
|
31
|
+
}, [center]); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
+
|
|
27
33
|
var defaultZoom = useMemo(function () {
|
|
28
34
|
return zoom || instance.config.zoom;
|
|
29
|
-
}, [zoom]);
|
|
30
|
-
|
|
35
|
+
}, [zoom]); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
|
+
|
|
31
37
|
var mapRest = useCallback(function () {
|
|
32
38
|
return instance.setZoomAndCenter(defaultZoom, defaultCenter);
|
|
33
39
|
}, [defaultZoom, defaultCenter]);
|
|
40
|
+
|
|
34
41
|
_useMount(function () {
|
|
35
42
|
return mapRest();
|
|
36
43
|
});
|
|
44
|
+
|
|
37
45
|
_useUpdateEffect(function () {
|
|
38
46
|
return instance.setZoomAndCenter(defaultZoom, defaultCenter);
|
|
39
47
|
}, [defaultZoom, defaultCenter]);
|
|
48
|
+
|
|
40
49
|
useEffect(function () {
|
|
41
50
|
if (selectCenter) {
|
|
42
51
|
instance.setZoomAndCenter(defaultZoom, selectCenter);
|
|
43
52
|
}
|
|
44
53
|
}, [defaultZoom, instance, selectCenter]);
|
|
45
|
-
return /*#__PURE__*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
55
|
+
children: [/*#__PURE__*/_jsx(ClusterLayer, {
|
|
56
|
+
points: points,
|
|
57
|
+
onPointClick: onPointClick
|
|
58
|
+
}), /*#__PURE__*/_jsx(ResetTools, {
|
|
59
|
+
onMapReset: mapRest
|
|
60
|
+
}), /*#__PURE__*/_jsx(MouseTool, {
|
|
61
|
+
ui: drawUi,
|
|
62
|
+
drawType: drawType,
|
|
63
|
+
drawEnd: drawEnd,
|
|
64
|
+
points: points
|
|
65
|
+
}), children]
|
|
66
|
+
});
|
|
56
67
|
}
|
|
68
|
+
|
|
57
69
|
export default withMap(MapDrawSelect, 'map-draw-select-container');
|
|
@@ -1,40 +1,54 @@
|
|
|
1
1
|
import _useUpdateEffect from "ahooks/es/useUpdateEffect";
|
|
2
2
|
import _nextTick from "@cloud-app-dev/utils/es/nextTick";
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import useMouseTools from
|
|
4
|
+
import useMouseTools from "./useMouseTools";
|
|
5
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
|
|
5
8
|
function MouseTool(_ref) {
|
|
6
9
|
var ui = _ref.ui,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
drawType = _ref.drawType,
|
|
11
|
+
_ref$points = _ref.points,
|
|
12
|
+
points = _ref$points === void 0 ? [] : _ref$points,
|
|
13
|
+
drawEnd = _ref.drawEnd;
|
|
14
|
+
|
|
11
15
|
var _useMouseTools = useMouseTools(function (obj) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
var selectPoints = [];
|
|
17
|
+
|
|
18
|
+
for (var i = 0; i < points.length; i++) {
|
|
19
|
+
var item = points[i];
|
|
20
|
+
|
|
21
|
+
if (item.longitude && item.latitude && obj.contains([item.longitude, item.latitude])) {
|
|
22
|
+
selectPoints.push(item);
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_nextTick(function () {
|
|
27
|
+
return drawEnd === null || drawEnd === void 0 ? void 0 : drawEnd(selectPoints);
|
|
28
|
+
});
|
|
29
|
+
}),
|
|
30
|
+
draw = _useMouseTools.draw,
|
|
31
|
+
close = _useMouseTools.close;
|
|
32
|
+
|
|
25
33
|
_useUpdateEffect(function () {
|
|
26
34
|
switch (drawType) {
|
|
27
35
|
case 'clear':
|
|
28
36
|
close(true);
|
|
29
37
|
break;
|
|
38
|
+
|
|
30
39
|
case 'close':
|
|
31
40
|
close();
|
|
32
41
|
break;
|
|
42
|
+
|
|
33
43
|
default:
|
|
34
44
|
draw(drawType);
|
|
35
45
|
break;
|
|
36
46
|
}
|
|
37
47
|
}, [drawType]);
|
|
38
|
-
|
|
48
|
+
|
|
49
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
50
|
+
children: ui
|
|
51
|
+
});
|
|
39
52
|
}
|
|
53
|
+
|
|
40
54
|
export default MouseTool;
|
|
@@ -1,77 +1,106 @@
|
|
|
1
1
|
import _useMount from "ahooks/es/useMount";
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
|
|
2
9
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
|
|
3
11
|
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."); }
|
|
12
|
+
|
|
4
13
|
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); }
|
|
14
|
+
|
|
5
15
|
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; }
|
|
16
|
+
|
|
6
17
|
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; }
|
|
18
|
+
|
|
7
19
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
+
|
|
8
21
|
import { useContext, useEffect, useRef, useState } from 'react';
|
|
9
|
-
import { mapContext } from
|
|
22
|
+
import { mapContext } from "../Context";
|
|
23
|
+
|
|
10
24
|
function useMouseTools(onDrawEnd) {
|
|
11
25
|
var _useState = useState({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
26
|
+
focusKey: Date.now()
|
|
27
|
+
}),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
state = _useState2[0],
|
|
30
|
+
setState = _useState2[1];
|
|
31
|
+
|
|
17
32
|
var _useContext = useContext(mapContext),
|
|
18
|
-
|
|
33
|
+
instance = _useContext.instance;
|
|
34
|
+
|
|
19
35
|
var overlayersRef = useRef([]);
|
|
20
36
|
var mouseRef = useRef(null);
|
|
37
|
+
|
|
21
38
|
_useMount(function () {
|
|
22
39
|
var map = instance.map;
|
|
23
40
|
AMap.plugin(['AMap.MouseTool'], function () {
|
|
24
41
|
mouseRef.current = new AMap.MouseTool(map);
|
|
25
42
|
setState(function (old) {
|
|
26
|
-
return
|
|
43
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
27
44
|
focusKey: Date.now()
|
|
28
45
|
});
|
|
29
46
|
});
|
|
30
47
|
});
|
|
31
48
|
});
|
|
49
|
+
|
|
32
50
|
useEffect(function () {
|
|
33
51
|
if (!mouseRef.current) {
|
|
34
52
|
return undefined;
|
|
35
53
|
}
|
|
54
|
+
|
|
36
55
|
var fn = function fn(e) {
|
|
37
56
|
overlayersRef.current.push(e.obj);
|
|
38
57
|
onDrawEnd === null || onDrawEnd === void 0 ? void 0 : onDrawEnd(e.obj);
|
|
39
58
|
};
|
|
59
|
+
|
|
40
60
|
mouseRef.current.on('draw', fn);
|
|
41
61
|
return function () {
|
|
42
62
|
mouseRef.current.off('draw', fn);
|
|
43
63
|
};
|
|
44
64
|
}, [onDrawEnd, state.focusKey]);
|
|
65
|
+
|
|
45
66
|
var draw = function draw(type) {
|
|
46
67
|
if (!mouseRef.current) {
|
|
47
68
|
return;
|
|
48
69
|
}
|
|
70
|
+
|
|
49
71
|
switch (type) {
|
|
50
72
|
case 'rect':
|
|
51
73
|
mouseRef.current.rectangle();
|
|
52
74
|
break;
|
|
75
|
+
|
|
53
76
|
case 'polygon':
|
|
54
77
|
mouseRef.current.polygon();
|
|
55
78
|
break;
|
|
79
|
+
|
|
56
80
|
case 'circle':
|
|
57
81
|
mouseRef.current.circle();
|
|
58
82
|
}
|
|
59
83
|
};
|
|
84
|
+
|
|
60
85
|
var clear = function clear(objs) {
|
|
61
86
|
objs.forEach(function (obj) {
|
|
62
87
|
instance.map.remove(obj);
|
|
63
88
|
});
|
|
64
89
|
};
|
|
90
|
+
|
|
65
91
|
var close = function close(ifClear) {
|
|
66
92
|
if (!mouseRef.current) {
|
|
67
93
|
return;
|
|
68
94
|
}
|
|
95
|
+
|
|
69
96
|
mouseRef.current.close(ifClear);
|
|
70
97
|
};
|
|
98
|
+
|
|
71
99
|
return {
|
|
72
100
|
clear: clear,
|
|
73
101
|
draw: draw,
|
|
74
102
|
close: close
|
|
75
103
|
};
|
|
76
104
|
}
|
|
105
|
+
|
|
77
106
|
export default useMouseTools;
|