@reltio/components 1.4.2257 → 1.4.2259
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/ReltioMap/ReltioMap.d.ts +5 -8
- package/ReltioMap/ReltioMap.js +31 -39
- package/ReltioMap/ReltioMap.spec.js +299 -104
- package/ReltioMap/components/ClusteredMarkers/ClusteredMarkers.d.ts +2 -1
- package/ReltioMap/components/ClusteredMarkers/ClusteredMarkers.js +11 -13
- package/ReltioMap/components/EntityMarker/EntityMarker.d.ts +2 -1
- package/ReltioMap/components/EntityMarker/EntityMarker.js +3 -3
- package/ReltioMap/components/PolygonDrawing/PolygonDrawing.d.ts +4 -0
- package/ReltioMap/components/PolygonDrawing/PolygonDrawing.js +18 -0
- package/ReltioMap/components/PolygonDrawing/crosshair.inline.svg.d.ts +1 -0
- package/ReltioMap/components/PolygonDrawing/crosshair.inline.svg.js +1 -0
- package/ReltioMap/components/PolygonDrawing/index.d.ts +2 -0
- package/ReltioMap/components/PolygonDrawing/index.js +2 -0
- package/ReltioMap/components/PolygonDrawing/polygonRingHelpers.d.ts +5 -0
- package/ReltioMap/components/PolygonDrawing/polygonRingHelpers.js +43 -0
- package/ReltioMap/components/PolygonDrawing/useDrawingCursors.d.ts +6 -0
- package/ReltioMap/components/PolygonDrawing/useDrawingCursors.js +87 -0
- package/ReltioMap/components/PolygonDrawing/usePolygonDrawing.d.ts +9 -0
- package/ReltioMap/components/PolygonDrawing/usePolygonDrawing.js +197 -0
- package/ReltioMap/components/PolygonDrawing/usePreviewPolylines.d.ts +7 -0
- package/ReltioMap/components/PolygonDrawing/usePreviewPolylines.js +38 -0
- package/ReltioMap/components/PolygonDrawing/useVertexHandles.d.ts +14 -0
- package/ReltioMap/components/PolygonDrawing/useVertexHandles.js +85 -0
- package/ReltioMap/components/TopRightMapControls/TopRightMapControls.d.ts +3 -3
- package/ReltioMap/components/TopRightMapControls/TopRightMapControls.js +4 -18
- package/ReltioMap/helpers.d.ts +2 -1
- package/ReltioMap/helpers.js +3 -11
- package/ReltioMap/types.d.ts +2 -2
- package/cjs/ReltioMap/ReltioMap.d.ts +5 -8
- package/cjs/ReltioMap/ReltioMap.js +29 -37
- package/cjs/ReltioMap/ReltioMap.spec.js +298 -103
- package/cjs/ReltioMap/components/ClusteredMarkers/ClusteredMarkers.d.ts +2 -1
- package/cjs/ReltioMap/components/ClusteredMarkers/ClusteredMarkers.js +11 -13
- package/cjs/ReltioMap/components/EntityMarker/EntityMarker.d.ts +2 -1
- package/cjs/ReltioMap/components/EntityMarker/EntityMarker.js +3 -3
- package/cjs/ReltioMap/components/PolygonDrawing/PolygonDrawing.d.ts +4 -0
- package/cjs/ReltioMap/components/PolygonDrawing/PolygonDrawing.js +22 -0
- package/cjs/ReltioMap/components/PolygonDrawing/crosshair.inline.svg.d.ts +1 -0
- package/cjs/ReltioMap/components/PolygonDrawing/crosshair.inline.svg.js +4 -0
- package/cjs/ReltioMap/components/PolygonDrawing/index.d.ts +2 -0
- package/cjs/ReltioMap/components/PolygonDrawing/index.js +7 -0
- package/cjs/ReltioMap/components/PolygonDrawing/polygonRingHelpers.d.ts +5 -0
- package/cjs/ReltioMap/components/PolygonDrawing/polygonRingHelpers.js +50 -0
- package/cjs/ReltioMap/components/PolygonDrawing/useDrawingCursors.d.ts +6 -0
- package/cjs/ReltioMap/components/PolygonDrawing/useDrawingCursors.js +91 -0
- package/cjs/ReltioMap/components/PolygonDrawing/usePolygonDrawing.d.ts +9 -0
- package/cjs/ReltioMap/components/PolygonDrawing/usePolygonDrawing.js +202 -0
- package/cjs/ReltioMap/components/PolygonDrawing/usePreviewPolylines.d.ts +7 -0
- package/cjs/ReltioMap/components/PolygonDrawing/usePreviewPolylines.js +42 -0
- package/cjs/ReltioMap/components/PolygonDrawing/useVertexHandles.d.ts +14 -0
- package/cjs/ReltioMap/components/PolygonDrawing/useVertexHandles.js +89 -0
- package/cjs/ReltioMap/components/TopRightMapControls/TopRightMapControls.d.ts +3 -3
- package/cjs/ReltioMap/components/TopRightMapControls/TopRightMapControls.js +3 -17
- package/cjs/ReltioMap/helpers.d.ts +2 -1
- package/cjs/ReltioMap/helpers.js +8 -15
- package/cjs/ReltioMap/types.d.ts +2 -2
- package/cjs/constants/index.d.ts +1 -1
- package/cjs/constants/index.js +2 -2
- package/cjs/constants/map.d.ts +1 -2
- package/cjs/constants/map.js +2 -5
- package/cjs/features/workflow/AddWorkflowDialog/styles.d.ts +1 -1
- package/cjs/icons/index.d.ts +0 -1
- package/cjs/icons/index.js +2 -4
- package/constants/index.d.ts +1 -1
- package/constants/index.js +1 -1
- package/constants/map.d.ts +1 -2
- package/constants/map.js +1 -4
- package/features/workflow/AddWorkflowDialog/styles.d.ts +1 -1
- package/icons/index.d.ts +0 -1
- package/icons/index.js +0 -1
- package/package.json +2 -2
- package/ReltioMap/components/DrawingManager/DrawingManager.d.ts +0 -2
- package/ReltioMap/components/DrawingManager/DrawingManager.js +0 -5
- package/ReltioMap/components/DrawingManager/index.d.ts +0 -1
- package/ReltioMap/components/DrawingManager/index.js +0 -1
- package/ReltioMap/components/DrawingManager/useDrawingManager.d.ts +0 -7
- package/ReltioMap/components/DrawingManager/useDrawingManager.js +0 -36
- package/ReltioMap/googleMock.test-data.d.ts +0 -1
- package/ReltioMap/googleMock.test-data.js +0 -109
- package/cjs/ReltioMap/components/DrawingManager/DrawingManager.d.ts +0 -2
- package/cjs/ReltioMap/components/DrawingManager/DrawingManager.js +0 -9
- package/cjs/ReltioMap/components/DrawingManager/index.d.ts +0 -1
- package/cjs/ReltioMap/components/DrawingManager/index.js +0 -5
- package/cjs/ReltioMap/components/DrawingManager/useDrawingManager.d.ts +0 -7
- package/cjs/ReltioMap/components/DrawingManager/useDrawingManager.js +0 -40
- package/cjs/ReltioMap/googleMock.test-data.d.ts +0 -1
- package/cjs/ReltioMap/googleMock.test-data.js +0 -113
- package/cjs/icons/Radius.d.ts +0 -3
- package/cjs/icons/Radius.js +0 -22
- package/icons/Radius.d.ts +0 -3
- package/icons/Radius.js +0 -17
|
@@ -6,6 +6,7 @@ type Props = {
|
|
|
6
6
|
enabledClustering: boolean;
|
|
7
7
|
options?: ClusteredMarkersOptions;
|
|
8
8
|
onMarkerClick?: (marker: GeoPoint) => void;
|
|
9
|
+
disabled?: boolean;
|
|
9
10
|
};
|
|
10
|
-
export declare const ClusteredMarkers: React.MemoExoticComponent<({ entityMarkers, options, enabledClustering, onMarkerClick }: Props) => React.JSX.Element>;
|
|
11
|
+
export declare const ClusteredMarkers: React.MemoExoticComponent<({ entityMarkers, options, enabledClustering, onMarkerClick, disabled }: Props) => React.JSX.Element>;
|
|
11
12
|
export {};
|
|
@@ -42,28 +42,26 @@ var react_1 = __importStar(require("react"));
|
|
|
42
42
|
var EntityMarker_1 = require("../EntityMarker");
|
|
43
43
|
var CustomClusterRenderer_1 = require("./CustomClusterRenderer");
|
|
44
44
|
exports.ClusteredMarkers = (0, react_1.memo)(function (_a) {
|
|
45
|
-
var entityMarkers = _a.entityMarkers, options = _a.options, enabledClustering = _a.enabledClustering, onMarkerClick = _a.onMarkerClick;
|
|
45
|
+
var entityMarkers = _a.entityMarkers, options = _a.options, enabledClustering = _a.enabledClustering, onMarkerClick = _a.onMarkerClick, disabled = _a.disabled;
|
|
46
46
|
var _b = (0, react_1.useState)({}), markers = _b[0], setMarkers = _b[1];
|
|
47
47
|
var map = (0, react_google_maps_1.useMap)();
|
|
48
48
|
var clusterer = (0, react_1.useMemo)(function () {
|
|
49
49
|
if (!enabledClustering || !map)
|
|
50
50
|
return null;
|
|
51
|
-
return new markerclusterer_1.MarkerClusterer({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}, [map, options, enabledClustering]);
|
|
57
|
-
(0, react_1.useEffect)(function () {
|
|
58
|
-
return function () {
|
|
59
|
-
clusterer === null || clusterer === void 0 ? void 0 : clusterer.onRemove();
|
|
60
|
-
};
|
|
61
|
-
}, [entityMarkers]);
|
|
51
|
+
return new markerclusterer_1.MarkerClusterer(__assign({ map: map, renderer: new CustomClusterRenderer_1.CustomClusterRenderer(options), algorithmOptions: { maxZoom: options === null || options === void 0 ? void 0 : options.maxZoom } }, (disabled
|
|
52
|
+
? {
|
|
53
|
+
onClusterClick: null
|
|
54
|
+
}
|
|
55
|
+
: {})));
|
|
56
|
+
}, [map, options, enabledClustering, disabled]);
|
|
62
57
|
(0, react_1.useEffect)(function () {
|
|
63
58
|
if (!clusterer)
|
|
64
59
|
return;
|
|
65
60
|
clusterer.clearMarkers();
|
|
66
61
|
clusterer.addMarkers(Object.values(markers));
|
|
62
|
+
return function () {
|
|
63
|
+
clusterer.onRemove();
|
|
64
|
+
};
|
|
67
65
|
}, [clusterer, markers]);
|
|
68
66
|
var setMarkerRef = (0, react_1.useCallback)(function (marker, key) {
|
|
69
67
|
setMarkers(function (markers) {
|
|
@@ -79,6 +77,6 @@ exports.ClusteredMarkers = (0, react_1.memo)(function (_a) {
|
|
|
79
77
|
}
|
|
80
78
|
});
|
|
81
79
|
}, []);
|
|
82
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, entityMarkers.filter((0, ramda_1.prop)('point')).map(function (marker) { return (react_1.default.createElement(EntityMarker_1.EntityMarker, { key: marker.id, marker: marker, clusterer: enabledClustering ? setMarkerRef : undefined, onClick: onMarkerClick })); })));
|
|
80
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, entityMarkers.filter((0, ramda_1.prop)('point')).map(function (marker) { return (react_1.default.createElement(EntityMarker_1.EntityMarker, { key: marker.id, marker: marker, clusterer: enabledClustering ? setMarkerRef : undefined, onClick: onMarkerClick, disabled: disabled })); })));
|
|
83
81
|
});
|
|
84
82
|
exports.ClusteredMarkers.displayName = 'ClusteredMarkers';
|
|
@@ -5,6 +5,7 @@ type Props = {
|
|
|
5
5
|
marker: GeoPoint;
|
|
6
6
|
onClick: (marker: GeoPoint) => void;
|
|
7
7
|
clusterer?: (advancedMarker: google.maps.marker.AdvancedMarkerElement | null, id: string) => void;
|
|
8
|
+
disabled?: boolean;
|
|
8
9
|
} & Omit<ComponentProps<typeof AdvancedMarker>, 'onClick' | 'position' | 'onMouseEnter' | 'onMouseLeave'>;
|
|
9
|
-
declare const _default: React.MemoExoticComponent<({ marker, onClick, clusterer, ...otherProps }: Props) => React.JSX.Element>;
|
|
10
|
+
declare const _default: React.MemoExoticComponent<({ marker, onClick, clusterer, disabled, ...otherProps }: Props) => React.JSX.Element>;
|
|
10
11
|
export default _default;
|
|
@@ -62,7 +62,7 @@ var hoveredMarkerIcon = (0, mdm_sdk_1.svg2Url)(marker_hover_inline_svg_1.HOVERED
|
|
|
62
62
|
var markerIcon = (0, mdm_sdk_1.svg2Url)(marker_inline_svg_1.MARKER);
|
|
63
63
|
var EntityMarker = function (_a) {
|
|
64
64
|
var _b;
|
|
65
|
-
var marker = _a.marker, onClick = _a.onClick, clusterer = _a.clusterer, otherProps = __rest(_a, ["marker", "onClick", "clusterer"]);
|
|
65
|
+
var marker = _a.marker, onClick = _a.onClick, clusterer = _a.clusterer, disabled = _a.disabled, otherProps = __rest(_a, ["marker", "onClick", "clusterer", "disabled"]);
|
|
66
66
|
var styles = (0, styles_1.useStyles)();
|
|
67
67
|
var _c = (0, react_1.useState)(false), hovered = _c[0], setHovered = _c[1];
|
|
68
68
|
var activeEntityUri = (0, react_1.useContext)(EntityMarkerContext_1.EntityMarkerContext).activeEntityUri;
|
|
@@ -79,7 +79,7 @@ var EntityMarker = function (_a) {
|
|
|
79
79
|
}, [clusterer, marker.id]);
|
|
80
80
|
var anchorEl = (_b = advancedMarkerRef.current) === null || _b === void 0 ? void 0 : _b.element;
|
|
81
81
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
82
|
-
anchorEl && (react_1.default.createElement(Popper_1.Popper, { anchorEl: anchorEl, open: hovered, className: styles.popper, modal: false, placement: "top", modifiers: [
|
|
82
|
+
anchorEl && !disabled && (react_1.default.createElement(Popper_1.Popper, { anchorEl: anchorEl, open: hovered, className: styles.popper, modal: false, placement: "top", modifiers: [
|
|
83
83
|
{
|
|
84
84
|
name: 'offset',
|
|
85
85
|
options: {
|
|
@@ -88,7 +88,7 @@ var EntityMarker = function (_a) {
|
|
|
88
88
|
}
|
|
89
89
|
] },
|
|
90
90
|
react_1.default.createElement(ProfileCard_1.ProfileCard, { entity: marker.entity, onMouseOver: onMouseOver, onMouseOut: onMouseOut }))),
|
|
91
|
-
react_1.default.createElement(react_google_maps_1.AdvancedMarker, __assign({ ref: ref, position: position, onClick: handleClick, onMouseEnter: onMouseOver, onMouseLeave: onMouseOut }, otherProps),
|
|
91
|
+
react_1.default.createElement(react_google_maps_1.AdvancedMarker, __assign({ ref: ref, position: position, onClick: disabled ? undefined : handleClick, onMouseEnter: disabled ? undefined : onMouseOver, onMouseLeave: disabled ? undefined : onMouseOut }, otherProps),
|
|
92
92
|
react_1.default.createElement("img", { "data-reltio-id": "marker-icon", src: hovered || isActive ? hoveredMarkerIcon : markerIcon }))));
|
|
93
93
|
};
|
|
94
94
|
exports.default = (0, react_1.memo)(EntityMarker);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.PolygonDrawing = void 0;
|
|
15
|
+
var react_google_maps_1 = require("@vis.gl/react-google-maps");
|
|
16
|
+
var usePolygonDrawing_1 = require("./usePolygonDrawing");
|
|
17
|
+
var PolygonDrawing = function (props) {
|
|
18
|
+
var map = (0, react_google_maps_1.useMap)();
|
|
19
|
+
(0, usePolygonDrawing_1.usePolygonDrawing)(__assign(__assign({}, props), { map: map }));
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
22
|
+
exports.PolygonDrawing = PolygonDrawing;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CROSSHAIR = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"15\" height=\"15\" viewBox=\"0 0 15 15\" shape-rendering=\"crispEdges\">\n <g fill=\"#FFFFFF\">\n <rect x=\"6\" y=\"0\" width=\"3\" height=\"1\"/>\n <rect x=\"6\" y=\"1\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"1\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"2\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"2\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"3\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"3\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"4\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"4\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"5\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"5\" width=\"1\" height=\"1\"/>\n <rect x=\"0\" y=\"6\" width=\"7\" height=\"1\"/>\n <rect x=\"8\" y=\"6\" width=\"7\" height=\"1\"/>\n <rect x=\"0\" y=\"7\" width=\"1\" height=\"1\"/>\n <rect x=\"14\" y=\"7\" width=\"1\" height=\"1\"/>\n <rect x=\"0\" y=\"8\" width=\"7\" height=\"1\"/>\n <rect x=\"8\" y=\"8\" width=\"7\" height=\"1\"/>\n <rect x=\"6\" y=\"9\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"9\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"10\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"10\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"11\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"11\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"12\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"12\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"13\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"13\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"14\" width=\"3\" height=\"1\"/>\n </g>\n <g fill=\"#000000\">\n <rect x=\"7\" y=\"1\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"2\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"3\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"4\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"5\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"6\" width=\"1\" height=\"1\"/>\n <rect x=\"1\" y=\"7\" width=\"13\" height=\"1\"/>\n <rect x=\"7\" y=\"8\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"9\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"10\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"11\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"12\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"13\" width=\"1\" height=\"1\"/>\n </g>\n</svg>";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CROSSHAIR = void 0;
|
|
4
|
+
exports.CROSSHAIR = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"15\" height=\"15\" viewBox=\"0 0 15 15\" shape-rendering=\"crispEdges\">\n <g fill=\"#FFFFFF\">\n <rect x=\"6\" y=\"0\" width=\"3\" height=\"1\"/>\n <rect x=\"6\" y=\"1\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"1\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"2\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"2\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"3\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"3\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"4\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"4\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"5\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"5\" width=\"1\" height=\"1\"/>\n <rect x=\"0\" y=\"6\" width=\"7\" height=\"1\"/>\n <rect x=\"8\" y=\"6\" width=\"7\" height=\"1\"/>\n <rect x=\"0\" y=\"7\" width=\"1\" height=\"1\"/>\n <rect x=\"14\" y=\"7\" width=\"1\" height=\"1\"/>\n <rect x=\"0\" y=\"8\" width=\"7\" height=\"1\"/>\n <rect x=\"8\" y=\"8\" width=\"7\" height=\"1\"/>\n <rect x=\"6\" y=\"9\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"9\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"10\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"10\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"11\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"11\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"12\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"12\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"13\" width=\"1\" height=\"1\"/>\n <rect x=\"8\" y=\"13\" width=\"1\" height=\"1\"/>\n <rect x=\"6\" y=\"14\" width=\"3\" height=\"1\"/>\n </g>\n <g fill=\"#000000\">\n <rect x=\"7\" y=\"1\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"2\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"3\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"4\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"5\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"6\" width=\"1\" height=\"1\"/>\n <rect x=\"1\" y=\"7\" width=\"13\" height=\"1\"/>\n <rect x=\"7\" y=\"8\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"9\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"10\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"11\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"12\" width=\"1\" height=\"1\"/>\n <rect x=\"7\" y=\"13\" width=\"1\" height=\"1\"/>\n </g>\n</svg>";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePolygonDrawing = exports.PolygonDrawing = void 0;
|
|
4
|
+
var PolygonDrawing_1 = require("./PolygonDrawing");
|
|
5
|
+
Object.defineProperty(exports, "PolygonDrawing", { enumerable: true, get: function () { return PolygonDrawing_1.PolygonDrawing; } });
|
|
6
|
+
var usePolygonDrawing_1 = require("./usePolygonDrawing");
|
|
7
|
+
Object.defineProperty(exports, "usePolygonDrawing", { enumerable: true, get: function () { return usePolygonDrawing_1.usePolygonDrawing; } });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const buildPolygonFromVertices: (vertices: readonly google.maps.LatLng[], options: google.maps.PolygonOptions) => google.maps.Polygon;
|
|
2
|
+
export declare const serializeRing: (vertices: readonly google.maps.LatLng[]) => [number, number][];
|
|
3
|
+
export declare const validateRing: (vertices: readonly google.maps.LatLng[] | null | undefined) => boolean;
|
|
4
|
+
/** Drops the last vertex when it duplicates the previous (e.g. double-click emits an extra click at the same lat/lng). */
|
|
5
|
+
export declare const dedupeTrailingDuplicateVertex: (vertices: readonly google.maps.LatLng[]) => google.maps.LatLng[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.dedupeTrailingDuplicateVertex = exports.validateRing = exports.serializeRing = exports.buildPolygonFromVertices = void 0;
|
|
24
|
+
var buildPolygonFromVertices = function (vertices, options) {
|
|
25
|
+
return new google.maps.Polygon(__assign({ paths: __spreadArray([], vertices, true), map: null }, options));
|
|
26
|
+
};
|
|
27
|
+
exports.buildPolygonFromVertices = buildPolygonFromVertices;
|
|
28
|
+
var serializeRing = function (vertices) {
|
|
29
|
+
return vertices.map(function (v) { return [v.lat(), v.lng()]; });
|
|
30
|
+
};
|
|
31
|
+
exports.serializeRing = serializeRing;
|
|
32
|
+
var validateRing = function (vertices) {
|
|
33
|
+
var _a;
|
|
34
|
+
return ((_a = vertices === null || vertices === void 0 ? void 0 : vertices.length) !== null && _a !== void 0 ? _a : 0) >= 3;
|
|
35
|
+
};
|
|
36
|
+
exports.validateRing = validateRing;
|
|
37
|
+
/** Drops the last vertex when it duplicates the previous (e.g. double-click emits an extra click at the same lat/lng). */
|
|
38
|
+
var dedupeTrailingDuplicateVertex = function (vertices) {
|
|
39
|
+
var out = __spreadArray([], vertices, true);
|
|
40
|
+
if (out.length < 2) {
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
var last = out[out.length - 1];
|
|
44
|
+
var prev = out[out.length - 2];
|
|
45
|
+
if (last && prev && last.equals(prev)) {
|
|
46
|
+
out.pop();
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
};
|
|
50
|
+
exports.dedupeTrailingDuplicateVertex = dedupeTrailingDuplicateVertex;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDrawingCursors = exports.MAP_DRAWING_CROSSHAIR_CURSOR = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
6
|
+
var crosshair_inline_svg_1 = require("./crosshair.inline.svg");
|
|
7
|
+
var helpers_1 = require("../../helpers");
|
|
8
|
+
var crosshairCursorDataUrl = (0, mdm_sdk_1.svg2CursorUrl)(crosshair_inline_svg_1.CROSSHAIR);
|
|
9
|
+
exports.MAP_DRAWING_CROSSHAIR_CURSOR = "url(\"".concat(crosshairCursorDataUrl, "\") 7 7, crosshair");
|
|
10
|
+
var useDrawingCursors = function (map, isActive) {
|
|
11
|
+
var applyDrawingCursorsIfChangedRef = (0, react_1.useRef)(function () { });
|
|
12
|
+
var reapplyCursors = (0, react_1.useCallback)(function () {
|
|
13
|
+
applyDrawingCursorsIfChangedRef.current();
|
|
14
|
+
}, []);
|
|
15
|
+
(0, react_1.useEffect)(function () {
|
|
16
|
+
if (!map || !isActive) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
var mapDiv = map.getDiv();
|
|
20
|
+
var isMapDragging = false;
|
|
21
|
+
var lastCursor = '';
|
|
22
|
+
var moRaf = null;
|
|
23
|
+
var getCurrentCursor = function () { return (isMapDragging ? 'grabbing' : exports.MAP_DRAWING_CROSSHAIR_CURSOR); };
|
|
24
|
+
var applyInlineCursorOnAdvancedMarkers = function (cursor) {
|
|
25
|
+
if (!(0, helpers_1.isDomElement)(mapDiv)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
mapDiv.querySelectorAll('gmp-advanced-marker').forEach(function (el) {
|
|
29
|
+
if (el instanceof HTMLElement) {
|
|
30
|
+
el.style.setProperty('cursor', cursor, 'important');
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var apply = function () {
|
|
35
|
+
var cursor = getCurrentCursor();
|
|
36
|
+
if ((0, helpers_1.isDomElement)(mapDiv)) {
|
|
37
|
+
if (lastCursor !== cursor) {
|
|
38
|
+
lastCursor = cursor;
|
|
39
|
+
mapDiv.style.setProperty('cursor', cursor, 'important');
|
|
40
|
+
}
|
|
41
|
+
applyInlineCursorOnAdvancedMarkers(cursor);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var applyAfterDomMutations = function () {
|
|
45
|
+
if (!(0, helpers_1.isDomElement)(mapDiv) || moRaf !== null) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
moRaf = requestAnimationFrame(function () {
|
|
49
|
+
moRaf = null;
|
|
50
|
+
applyInlineCursorOnAdvancedMarkers(getCurrentCursor());
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
var mapDomObserver = (0, helpers_1.isDomElement)(mapDiv) ? new MutationObserver(applyAfterDomMutations) : null;
|
|
54
|
+
if (mapDomObserver) {
|
|
55
|
+
mapDomObserver.observe(mapDiv, { childList: true, subtree: true });
|
|
56
|
+
}
|
|
57
|
+
var reapplyCursorsToDom = function () {
|
|
58
|
+
lastCursor = '';
|
|
59
|
+
apply();
|
|
60
|
+
};
|
|
61
|
+
applyDrawingCursorsIfChangedRef.current = reapplyCursorsToDom;
|
|
62
|
+
var dragStartListener = map.addListener('dragstart', function () {
|
|
63
|
+
isMapDragging = true;
|
|
64
|
+
apply();
|
|
65
|
+
});
|
|
66
|
+
var dragEndListener = map.addListener('dragend', function () {
|
|
67
|
+
isMapDragging = false;
|
|
68
|
+
apply();
|
|
69
|
+
});
|
|
70
|
+
apply();
|
|
71
|
+
return function () {
|
|
72
|
+
applyDrawingCursorsIfChangedRef.current = function () { };
|
|
73
|
+
if (moRaf !== null) {
|
|
74
|
+
cancelAnimationFrame(moRaf);
|
|
75
|
+
}
|
|
76
|
+
mapDomObserver === null || mapDomObserver === void 0 ? void 0 : mapDomObserver.disconnect();
|
|
77
|
+
if ((0, helpers_1.isDomElement)(mapDiv)) {
|
|
78
|
+
mapDiv.querySelectorAll('gmp-advanced-marker').forEach(function (el) {
|
|
79
|
+
if (el instanceof HTMLElement) {
|
|
80
|
+
el.style.removeProperty('cursor');
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
mapDiv.style.removeProperty('cursor');
|
|
84
|
+
}
|
|
85
|
+
google.maps.event.removeListener(dragStartListener);
|
|
86
|
+
google.maps.event.removeListener(dragEndListener);
|
|
87
|
+
};
|
|
88
|
+
}, [map, isActive]);
|
|
89
|
+
return { reapplyCursors: reapplyCursors };
|
|
90
|
+
};
|
|
91
|
+
exports.useDrawingCursors = useDrawingCursors;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { MAP_DRAWING_CROSSHAIR_CURSOR } from './useDrawingCursors';
|
|
2
|
+
export type UsePolygonDrawingParams = {
|
|
3
|
+
map: google.maps.Map | null;
|
|
4
|
+
isActive: boolean;
|
|
5
|
+
previewPolylineOptions: google.maps.PolylineOptions;
|
|
6
|
+
completedPolygonOptions: google.maps.PolygonOptions;
|
|
7
|
+
onPolygonComplete: (polygon: google.maps.Polygon) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const usePolygonDrawing: ({ map, isActive, previewPolylineOptions, completedPolygonOptions, onPolygonComplete }: UsePolygonDrawingParams) => void;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.usePolygonDrawing = exports.MAP_DRAWING_CROSSHAIR_CURSOR = void 0;
|
|
13
|
+
var react_1 = require("react");
|
|
14
|
+
var helpers_1 = require("../../helpers");
|
|
15
|
+
var polygonRingHelpers_1 = require("./polygonRingHelpers");
|
|
16
|
+
var useDrawingCursors_1 = require("./useDrawingCursors");
|
|
17
|
+
var usePreviewPolylines_1 = require("./usePreviewPolylines");
|
|
18
|
+
var useVertexHandles_1 = require("./useVertexHandles");
|
|
19
|
+
var useDrawingCursors_2 = require("./useDrawingCursors");
|
|
20
|
+
Object.defineProperty(exports, "MAP_DRAWING_CROSSHAIR_CURSOR", { enumerable: true, get: function () { return useDrawingCursors_2.MAP_DRAWING_CROSSHAIR_CURSOR; } });
|
|
21
|
+
var usePolygonDrawing = function (_a) {
|
|
22
|
+
var map = _a.map, isActive = _a.isActive, previewPolylineOptions = _a.previewPolylineOptions, completedPolygonOptions = _a.completedPolygonOptions, onPolygonComplete = _a.onPolygonComplete;
|
|
23
|
+
var _b = (0, react_1.useState)([]), vertices = _b[0], setVertices = _b[1];
|
|
24
|
+
var verticesRef = (0, react_1.useRef)([]);
|
|
25
|
+
var completionLockRef = (0, react_1.useRef)(false);
|
|
26
|
+
var previewPolylineOptionsRef = (0, react_1.useRef)(previewPolylineOptions);
|
|
27
|
+
previewPolylineOptionsRef.current = previewPolylineOptions;
|
|
28
|
+
verticesRef.current = vertices;
|
|
29
|
+
var prevDisableDoubleClickZoom = (0, react_1.useRef)(undefined);
|
|
30
|
+
var prevClickableIcons = (0, react_1.useRef)(undefined);
|
|
31
|
+
var prevDraggableCursor = (0, react_1.useRef)(undefined);
|
|
32
|
+
var syncDisposeVertexHandlesRef = (0, react_1.useRef)(function () { });
|
|
33
|
+
(0, react_1.useEffect)(function () {
|
|
34
|
+
if (map && isActive) {
|
|
35
|
+
setVertices([]);
|
|
36
|
+
completionLockRef.current = false;
|
|
37
|
+
}
|
|
38
|
+
else if (!isActive) {
|
|
39
|
+
setVertices([]);
|
|
40
|
+
}
|
|
41
|
+
}, [map, isActive]);
|
|
42
|
+
var reapplyCursors = (0, useDrawingCursors_1.useDrawingCursors)(map, isActive).reapplyCursors;
|
|
43
|
+
var _c = (0, usePreviewPolylines_1.usePreviewPolylines)(map, previewPolylineOptionsRef, isActive), polylineRef = _c.polylineRef, rubberBandPolylineRef = _c.rubberBandPolylineRef, handleZIndexRef = _c.handleZIndexRef;
|
|
44
|
+
var reapplyCursorsRef = (0, react_1.useRef)(reapplyCursors);
|
|
45
|
+
reapplyCursorsRef.current = reapplyCursors;
|
|
46
|
+
var onPolygonCompleteRef = (0, react_1.useRef)(onPolygonComplete);
|
|
47
|
+
onPolygonCompleteRef.current = onPolygonComplete;
|
|
48
|
+
var completedPolygonOptionsRef = (0, react_1.useRef)(completedPolygonOptions);
|
|
49
|
+
completedPolygonOptionsRef.current = completedPolygonOptions;
|
|
50
|
+
var tryComplete = (0, react_1.useCallback)(function () {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
if (completionLockRef.current) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
var verts = (0, polygonRingHelpers_1.dedupeTrailingDuplicateVertex)(verticesRef.current);
|
|
56
|
+
if (!(0, polygonRingHelpers_1.validateRing)(verts)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
completionLockRef.current = true;
|
|
60
|
+
syncDisposeVertexHandlesRef.current();
|
|
61
|
+
(_a = rubberBandPolylineRef.current) === null || _a === void 0 ? void 0 : _a.setPath([]);
|
|
62
|
+
var polygon = (0, polygonRingHelpers_1.buildPolygonFromVertices)(verts, completedPolygonOptionsRef.current);
|
|
63
|
+
(_b = polylineRef.current) === null || _b === void 0 ? void 0 : _b.setPath([]);
|
|
64
|
+
setVertices([]);
|
|
65
|
+
reapplyCursorsRef.current();
|
|
66
|
+
onPolygonCompleteRef.current(polygon);
|
|
67
|
+
}, [polylineRef, rubberBandPolylineRef]);
|
|
68
|
+
var resetDraftPolygon = (0, react_1.useCallback)(function () {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
if (verticesRef.current.length === 0) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
setVertices([]);
|
|
74
|
+
(_a = polylineRef.current) === null || _a === void 0 ? void 0 : _a.setPath([]);
|
|
75
|
+
(_b = rubberBandPolylineRef.current) === null || _b === void 0 ? void 0 : _b.setPath([]);
|
|
76
|
+
reapplyCursorsRef.current();
|
|
77
|
+
}, [polylineRef, rubberBandPolylineRef]);
|
|
78
|
+
var tryCompleteRef = (0, react_1.useRef)(tryComplete);
|
|
79
|
+
tryCompleteRef.current = tryComplete;
|
|
80
|
+
var resetDraftPolygonRef = (0, react_1.useRef)(resetDraftPolygon);
|
|
81
|
+
resetDraftPolygonRef.current = resetDraftPolygon;
|
|
82
|
+
var previewPathVertexCountRef = (0, react_1.useRef)(0);
|
|
83
|
+
(0, useVertexHandles_1.useVertexHandles)({
|
|
84
|
+
map: map,
|
|
85
|
+
isActive: isActive,
|
|
86
|
+
vertices: vertices,
|
|
87
|
+
handleZIndexRef: handleZIndexRef,
|
|
88
|
+
onFirstHandleClick: tryComplete,
|
|
89
|
+
syncDisposeRef: syncDisposeVertexHandlesRef
|
|
90
|
+
});
|
|
91
|
+
(0, react_1.useEffect)(function () {
|
|
92
|
+
if (!isActive) {
|
|
93
|
+
previewPathVertexCountRef.current = 0;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
var line = polylineRef.current;
|
|
97
|
+
var band = rubberBandPolylineRef.current;
|
|
98
|
+
if (!line) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
var path = line.getPath();
|
|
102
|
+
var prev = previewPathVertexCountRef.current;
|
|
103
|
+
var vertexCount = vertices.length;
|
|
104
|
+
if (vertexCount === 0) {
|
|
105
|
+
if (path.getLength() > 0) {
|
|
106
|
+
path.clear();
|
|
107
|
+
}
|
|
108
|
+
band === null || band === void 0 ? void 0 : band.setPath([]);
|
|
109
|
+
previewPathVertexCountRef.current = 0;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
var pathLen = path.getLength();
|
|
113
|
+
if (vertexCount < prev) {
|
|
114
|
+
line.setPath(vertices);
|
|
115
|
+
}
|
|
116
|
+
else if (vertexCount === prev + 1 && pathLen === prev) {
|
|
117
|
+
var added = vertices[vertexCount - 1];
|
|
118
|
+
if (added) {
|
|
119
|
+
path.push(added);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else if (vertexCount !== prev || pathLen !== vertexCount) {
|
|
123
|
+
line.setPath(vertices);
|
|
124
|
+
}
|
|
125
|
+
previewPathVertexCountRef.current = vertexCount;
|
|
126
|
+
var last = vertices[vertexCount - 1];
|
|
127
|
+
if (last) {
|
|
128
|
+
band === null || band === void 0 ? void 0 : band.setPath([last, last]);
|
|
129
|
+
}
|
|
130
|
+
}, [isActive, vertices, polylineRef, rubberBandPolylineRef]);
|
|
131
|
+
(0, react_1.useEffect)(function () {
|
|
132
|
+
if (!map || !isActive) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
prevDisableDoubleClickZoom.current = map.get('disableDoubleClickZoom');
|
|
136
|
+
prevClickableIcons.current = map.get('clickableIcons');
|
|
137
|
+
prevDraggableCursor.current = map.get('draggableCursor');
|
|
138
|
+
var mapDiv = map.getDiv();
|
|
139
|
+
var rubber = rubberBandPolylineRef;
|
|
140
|
+
var updateRubberBand = function (latLngFromEvent) {
|
|
141
|
+
var _a, _b, _c;
|
|
142
|
+
var verts = verticesRef.current;
|
|
143
|
+
if (!verts.length || !latLngFromEvent) {
|
|
144
|
+
(_a = rubber.current) === null || _a === void 0 ? void 0 : _a.setPath([]);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
var last = verts[verts.length - 1];
|
|
148
|
+
if (!last) {
|
|
149
|
+
(_b = rubber.current) === null || _b === void 0 ? void 0 : _b.setPath([]);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
(_c = rubber.current) === null || _c === void 0 ? void 0 : _c.setPath([last, latLngFromEvent]);
|
|
153
|
+
};
|
|
154
|
+
map.setOptions({
|
|
155
|
+
disableDoubleClickZoom: true,
|
|
156
|
+
clickableIcons: false,
|
|
157
|
+
draggableCursor: useDrawingCursors_1.MAP_DRAWING_CROSSHAIR_CURSOR
|
|
158
|
+
});
|
|
159
|
+
var mouseMoveListener = map.addListener('mousemove', function (e) {
|
|
160
|
+
var _a;
|
|
161
|
+
updateRubberBand((_a = e.latLng) !== null && _a !== void 0 ? _a : null);
|
|
162
|
+
});
|
|
163
|
+
var onDrawingClick = function (e) {
|
|
164
|
+
var latLng = e.latLng;
|
|
165
|
+
if (!latLng) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (completionLockRef.current) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
setVertices(function (vs) { return __spreadArray(__spreadArray([], vs, true), [latLng], false); });
|
|
172
|
+
};
|
|
173
|
+
var clickListener = map.addListener('click', onDrawingClick);
|
|
174
|
+
var onMapDivDblClick = function (ev) {
|
|
175
|
+
ev.preventDefault();
|
|
176
|
+
ev.stopPropagation();
|
|
177
|
+
tryCompleteRef.current();
|
|
178
|
+
};
|
|
179
|
+
var onMapDivMouseLeave = function () {
|
|
180
|
+
resetDraftPolygonRef.current();
|
|
181
|
+
};
|
|
182
|
+
if ((0, helpers_1.isDomElement)(mapDiv)) {
|
|
183
|
+
mapDiv.addEventListener('dblclick', onMapDivDblClick, true);
|
|
184
|
+
mapDiv.addEventListener('mouseleave', onMapDivMouseLeave);
|
|
185
|
+
}
|
|
186
|
+
return function () {
|
|
187
|
+
var _a;
|
|
188
|
+
if ((0, helpers_1.isDomElement)(mapDiv)) {
|
|
189
|
+
mapDiv.removeEventListener('dblclick', onMapDivDblClick, true);
|
|
190
|
+
mapDiv.removeEventListener('mouseleave', onMapDivMouseLeave);
|
|
191
|
+
}
|
|
192
|
+
google.maps.event.removeListener(mouseMoveListener);
|
|
193
|
+
google.maps.event.removeListener(clickListener);
|
|
194
|
+
map.setOptions({
|
|
195
|
+
disableDoubleClickZoom: (_a = prevDisableDoubleClickZoom.current) !== null && _a !== void 0 ? _a : false,
|
|
196
|
+
clickableIcons: prevClickableIcons.current !== undefined ? prevClickableIcons.current : true,
|
|
197
|
+
draggableCursor: prevDraggableCursor.current
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
}, [map, isActive]);
|
|
201
|
+
};
|
|
202
|
+
exports.usePolygonDrawing = usePolygonDrawing;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type MutableRefObject, type RefObject } from 'react';
|
|
2
|
+
export type PreviewPolylinesRefs = {
|
|
3
|
+
polylineRef: RefObject<google.maps.Polyline | null>;
|
|
4
|
+
rubberBandPolylineRef: RefObject<google.maps.Polyline | null>;
|
|
5
|
+
handleZIndexRef: RefObject<number>;
|
|
6
|
+
};
|
|
7
|
+
export declare const usePreviewPolylines: (map: google.maps.Map | null, previewPolylineOptionsRef: MutableRefObject<google.maps.PolylineOptions>, isActive: boolean) => PreviewPolylinesRefs;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.usePreviewPolylines = void 0;
|
|
15
|
+
var react_1 = require("react");
|
|
16
|
+
var usePreviewPolylines = function (map, previewPolylineOptionsRef, isActive) {
|
|
17
|
+
var polylineRef = (0, react_1.useRef)(null);
|
|
18
|
+
var rubberBandPolylineRef = (0, react_1.useRef)(null);
|
|
19
|
+
var handleZIndexRef = (0, react_1.useRef)(4);
|
|
20
|
+
(0, react_1.useEffect)(function () {
|
|
21
|
+
var _a;
|
|
22
|
+
if (!map || !isActive) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
var options = previewPolylineOptionsRef.current;
|
|
26
|
+
var polyline = new google.maps.Polyline(__assign(__assign({ map: map, path: [] }, options), { clickable: false, draggable: false, editable: false }));
|
|
27
|
+
var previewBandZ = ((_a = options.zIndex) !== null && _a !== void 0 ? _a : 2) + 1;
|
|
28
|
+
var rubberBandPolyline = new google.maps.Polyline(__assign(__assign({ map: map, path: [] }, options), { clickable: false, draggable: false, editable: false, zIndex: previewBandZ, strokeOpacity: Math.min(1, typeof options.strokeOpacity === 'number' ? options.strokeOpacity * 0.65 : 0.65) }));
|
|
29
|
+
handleZIndexRef.current = previewBandZ + 2;
|
|
30
|
+
polylineRef.current = polyline;
|
|
31
|
+
rubberBandPolylineRef.current = rubberBandPolyline;
|
|
32
|
+
return function () {
|
|
33
|
+
polyline.setMap(null);
|
|
34
|
+
rubberBandPolyline.setMap(null);
|
|
35
|
+
polylineRef.current = null;
|
|
36
|
+
rubberBandPolylineRef.current = null;
|
|
37
|
+
};
|
|
38
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
+
}, [map, isActive]);
|
|
40
|
+
return { polylineRef: polylineRef, rubberBandPolylineRef: rubberBandPolylineRef, handleZIndexRef: handleZIndexRef };
|
|
41
|
+
};
|
|
42
|
+
exports.usePreviewPolylines = usePreviewPolylines;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type MutableRefObject, type RefObject } from 'react';
|
|
2
|
+
export type UseVertexHandlesParams = {
|
|
3
|
+
map: google.maps.Map | null;
|
|
4
|
+
isActive: boolean;
|
|
5
|
+
vertices: readonly google.maps.LatLng[];
|
|
6
|
+
handleZIndexRef: RefObject<number>;
|
|
7
|
+
onFirstHandleClick: () => void;
|
|
8
|
+
syncDisposeRef: MutableRefObject<() => void>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* N circular vertex markers. The first is clickable to close the ring; others swallow clicks to avoid
|
|
12
|
+
* double map-handling.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useVertexHandles: ({ map, isActive, vertices, handleZIndexRef, onFirstHandleClick, syncDisposeRef }: UseVertexHandlesParams) => void;
|