@dynatrace/strato-geo 3.5.2 → 3.7.0
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/esm/map/MapView.js +42 -34
- package/esm/map/MapView.js.map +2 -2
- package/esm/map/components/BubbleLayer/BubbleCircleLayer.js +2 -0
- package/esm/map/components/BubbleLayer/BubbleCircleLayer.js.map +2 -2
- package/esm/map/components/BubbleLayer/BubbleLayer.js +14 -3
- package/esm/map/components/BubbleLayer/BubbleLayer.js.map +2 -2
- package/esm/map/components/BubbleLayer/BubbleLayerTooltip.js +9 -3
- package/esm/map/components/BubbleLayer/BubbleLayerTooltip.js.map +2 -2
- package/esm/map/components/BubbleLayer/utils/parse-bubble-data-to-geo-json.js +5 -5
- package/esm/map/components/BubbleLayer/utils/parse-bubble-data-to-geo-json.js.map +2 -2
- package/esm/map/components/ChoroplethLayer/ChoroplethLayer.js +15 -7
- package/esm/map/components/ChoroplethLayer/ChoroplethLayer.js.map +2 -2
- package/esm/map/components/ChoroplethLayer/ChoroplethLayerTooltip.js +9 -3
- package/esm/map/components/ChoroplethLayer/ChoroplethLayerTooltip.js.map +2 -2
- package/esm/map/components/ChoroplethLayer/ChoroplethOutlineLayer.js +3 -1
- package/esm/map/components/ChoroplethLayer/ChoroplethOutlineLayer.js.map +2 -2
- package/esm/map/components/ChoroplethLayer/utils/parse-region-data-to-geo-json.js +6 -5
- package/esm/map/components/ChoroplethLayer/utils/parse-region-data-to-geo-json.js.map +2 -2
- package/esm/map/components/ConnectionLayer/ConnectionLayer.js +11 -6
- package/esm/map/components/ConnectionLayer/ConnectionLayer.js.map +2 -2
- package/esm/map/components/ConnectionLayer/ConnectionLayerLine.js +3 -0
- package/esm/map/components/ConnectionLayer/ConnectionLayerLine.js.map +2 -2
- package/esm/map/components/ConnectionLayer/ConnectionLayerTooltip.js +16 -12
- package/esm/map/components/ConnectionLayer/ConnectionLayerTooltip.js.map +2 -2
- package/esm/map/components/ConnectionLayer/utils/parse-connection-data-to-geo-json.js +20 -18
- package/esm/map/components/ConnectionLayer/utils/parse-connection-data-to-geo-json.js.map +2 -2
- package/esm/map/components/DotLayer/DotLayer.js +12 -3
- package/esm/map/components/DotLayer/DotLayer.js.map +2 -2
- package/esm/map/components/DotLayer/DotLayerTooltip.js +9 -3
- package/esm/map/components/DotLayer/DotLayerTooltip.js.map +2 -2
- package/esm/map/components/DotLayer/utils/parse-dot-data-to-geo-json.js +5 -5
- package/esm/map/components/DotLayer/utils/parse-dot-data-to-geo-json.js.map +2 -2
- package/esm/map/components/MapContent.js +22 -12
- package/esm/map/components/MapContent.js.map +2 -2
- package/esm/map/contexts/geo-data-lookup.context.js +8 -0
- package/esm/map/contexts/geo-data-lookup.context.js.map +7 -0
- package/esm/map/contexts/map-view-provider.context.js +9 -0
- package/esm/map/contexts/map-view-provider.context.js.map +7 -0
- package/esm/map/hooks/use-active-interaction.js +59 -43
- package/esm/map/hooks/use-active-interaction.js.map +2 -2
- package/esm/map/hooks/use-attach-image-from-icon.js +4 -2
- package/esm/map/hooks/use-attach-image-from-icon.js.map +2 -2
- package/esm/map/hooks/use-hover-interaction.js +59 -41
- package/esm/map/hooks/use-hover-interaction.js.map +2 -2
- package/esm/map/hooks/use-layer-before-id.js +24 -0
- package/esm/map/hooks/use-layer-before-id.js.map +7 -0
- package/esm/map/hooks/use-load-map-base-layer.js +13 -3
- package/esm/map/hooks/use-load-map-base-layer.js.map +2 -2
- package/esm/map/hooks/use-map-runtime-error.js +93 -0
- package/esm/map/hooks/use-map-runtime-error.js.map +7 -0
- package/esm/map/hooks/use-map-view-provider-context.js +7 -0
- package/esm/map/hooks/use-map-view-provider-context.js.map +7 -0
- package/esm/map/hooks/use-overlay-events.js +11 -2
- package/esm/map/hooks/use-overlay-events.js.map +2 -2
- package/esm/map/hooks/use-tooltip-template.js +17 -2
- package/esm/map/hooks/use-tooltip-template.js.map +2 -2
- package/esm/map/hooks/use-webgl-context-error.js +2 -1
- package/esm/map/hooks/use-webgl-context-error.js.map +2 -2
- package/esm/map/index.js +2 -0
- package/esm/map/index.js.map +2 -2
- package/esm/map/providers/map-view.provider.js +18 -0
- package/esm/map/providers/map-view.provider.js.map +7 -0
- package/esm/map/slots/Tooltip.js.map +2 -2
- package/esm/map/types/map-view-provider.js +1 -0
- package/esm/map/types/map-view-provider.js.map +7 -0
- package/esm/map/utils/attach-image-from-shape.js +4 -2
- package/esm/map/utils/attach-image-from-shape.js.map +2 -2
- package/esm/map/utils/extract-layers-data.js +24 -15
- package/esm/map/utils/extract-layers-data.js.map +2 -2
- package/esm/map/utils/fetch-base-layer-features.js +1 -1
- package/esm/map/utils/fetch-base-layer-features.js.map +2 -2
- package/esm/map/utils/is-browser-firefox.js +7 -0
- package/esm/map/utils/is-browser-firefox.js.map +7 -0
- package/esm/map/utils/parse-tooltip-data.js +22 -7
- package/esm/map/utils/parse-tooltip-data.js.map +2 -2
- package/map/MapView.js +42 -34
- package/map/components/BubbleLayer/BubbleCircleLayer.d.ts +2 -1
- package/map/components/BubbleLayer/BubbleCircleLayer.js +2 -0
- package/map/components/BubbleLayer/BubbleLayer.js +14 -3
- package/map/components/BubbleLayer/BubbleLayerTooltip.d.ts +2 -0
- package/map/components/BubbleLayer/BubbleLayerTooltip.js +9 -3
- package/map/components/BubbleLayer/utils/parse-bubble-data-to-geo-json.d.ts +3 -1
- package/map/components/BubbleLayer/utils/parse-bubble-data-to-geo-json.js +5 -5
- package/map/components/ChoroplethLayer/ChoroplethLayer.js +15 -7
- package/map/components/ChoroplethLayer/ChoroplethLayerTooltip.d.ts +2 -0
- package/map/components/ChoroplethLayer/ChoroplethLayerTooltip.js +9 -3
- package/map/components/ChoroplethLayer/ChoroplethOutlineLayer.d.ts +1 -0
- package/map/components/ChoroplethLayer/ChoroplethOutlineLayer.js +3 -1
- package/map/components/ChoroplethLayer/utils/parse-region-data-to-geo-json.d.ts +3 -1
- package/map/components/ChoroplethLayer/utils/parse-region-data-to-geo-json.js +6 -5
- package/map/components/ConnectionLayer/ConnectionLayer.js +11 -6
- package/map/components/ConnectionLayer/ConnectionLayerLine.js +3 -0
- package/map/components/ConnectionLayer/ConnectionLayerTooltip.d.ts +2 -0
- package/map/components/ConnectionLayer/ConnectionLayerTooltip.js +16 -12
- package/map/components/ConnectionLayer/utils/parse-connection-data-to-geo-json.d.ts +3 -1
- package/map/components/ConnectionLayer/utils/parse-connection-data-to-geo-json.js +20 -18
- package/map/components/DotLayer/DotLayer.js +12 -3
- package/map/components/DotLayer/DotLayerTooltip.d.ts +2 -0
- package/map/components/DotLayer/DotLayerTooltip.js +9 -3
- package/map/components/DotLayer/utils/parse-dot-data-to-geo-json.d.ts +3 -1
- package/map/components/DotLayer/utils/parse-dot-data-to-geo-json.js +5 -5
- package/map/components/MapContent.js +21 -12
- package/map/contexts/geo-data-lookup.context.d.ts +9 -0
- package/map/contexts/geo-data-lookup.context.js +27 -0
- package/map/contexts/map-view-provider.context.d.ts +2 -0
- package/map/{components/ConnectionLayer/utils/restore-null-props.js → contexts/map-view-provider.context.js} +8 -8
- package/map/hooks/use-active-interaction.d.ts +8 -1
- package/map/hooks/use-active-interaction.js +58 -42
- package/map/hooks/use-attach-image-from-icon.js +4 -2
- package/map/hooks/use-hover-interaction.d.ts +6 -2
- package/map/hooks/use-hover-interaction.js +52 -39
- package/map/hooks/use-layer-before-id.d.ts +13 -0
- package/map/hooks/{use-map-mouse-move.js → use-layer-before-id.js} +20 -15
- package/map/hooks/use-load-map-base-layer.js +13 -3
- package/map/hooks/use-map-runtime-error.d.ts +34 -0
- package/map/hooks/use-map-runtime-error.js +112 -0
- package/map/hooks/use-map-view-provider-context.d.ts +1 -0
- package/map/hooks/use-map-view-provider-context.js +26 -0
- package/map/hooks/use-overlay-events.js +11 -2
- package/map/hooks/use-tooltip-template.d.ts +8 -0
- package/map/hooks/use-tooltip-template.js +17 -2
- package/map/hooks/use-webgl-context-error.js +2 -1
- package/map/index.d.ts +2 -0
- package/map/index.js +2 -0
- package/map/providers/map-view.provider.d.ts +7 -0
- package/map/providers/map-view.provider.js +37 -0
- package/map/slots/Tooltip.d.ts +2 -0
- package/map/types/connection-layer.d.ts +1 -8
- package/map/types/map-view-provider.d.ts +10 -0
- package/map/types/map-view-provider.js +16 -0
- package/map/types/tooltip.d.ts +17 -0
- package/map/utils/attach-image-from-shape.js +4 -2
- package/map/utils/extract-layers-data.d.ts +2 -0
- package/map/utils/extract-layers-data.js +24 -15
- package/map/utils/fetch-base-layer-features.js +1 -1
- package/map/utils/is-browser-firefox.d.ts +5 -0
- package/map/utils/is-browser-firefox.js +26 -0
- package/map/utils/parse-tooltip-data.d.ts +11 -3
- package/map/utils/parse-tooltip-data.js +22 -7
- package/package.json +2 -2
- package/esm/map/components/ConnectionLayer/utils/restore-null-props.js +0 -9
- package/esm/map/components/ConnectionLayer/utils/restore-null-props.js.map +0 -7
- package/esm/map/hooks/use-map-mouse-move.js +0 -19
- package/esm/map/hooks/use-map-mouse-move.js.map +0 -7
- package/map/components/ConnectionLayer/utils/restore-null-props.d.ts +0 -2
- package/map/hooks/use-map-mouse-move.d.ts +0 -2
|
@@ -23,28 +23,26 @@ __export(ConnectionLayerTooltip_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(ConnectionLayerTooltip_exports);
|
|
24
24
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
25
|
var import_charts = require("@dynatrace/strato-components/charts");
|
|
26
|
-
var import_restore_null_props = require("./utils/restore-null-props.js");
|
|
27
26
|
var import_use_geo_layer_tooltip = require("../../hooks/use-geo-layer-tooltip.js");
|
|
28
27
|
var import_tooltip_type_guards = require("../../utils/tooltip-type-guards.js");
|
|
29
28
|
const ConnectionLayerTooltip = (props) => {
|
|
30
|
-
const { tooltipTemplate } = props;
|
|
31
|
-
const {
|
|
32
|
-
|
|
33
|
-
inBounds,
|
|
34
|
-
position
|
|
35
|
-
} = (0, import_use_geo_layer_tooltip.useGeoLayerTooltip)("geoConnection");
|
|
36
|
-
const data = (0, import_restore_null_props.restoreNullProps)(rawData);
|
|
37
|
-
if (!tooltipTemplate || !inBounds || !position) {
|
|
29
|
+
const { tooltipTemplate, hidden, symbolAlignment } = props;
|
|
30
|
+
const { data, inBounds, position } = (0, import_use_geo_layer_tooltip.useGeoLayerTooltip)("geoConnection");
|
|
31
|
+
if (hidden || !tooltipTemplate || !inBounds || !position) {
|
|
38
32
|
return null;
|
|
39
33
|
}
|
|
40
34
|
if (!data || !data[0]) {
|
|
41
35
|
return null;
|
|
42
36
|
}
|
|
43
|
-
const {
|
|
37
|
+
const {
|
|
38
|
+
__lineColor: color,
|
|
39
|
+
__lineWidth: thickness,
|
|
40
|
+
data: customData
|
|
41
|
+
} = data[0];
|
|
44
42
|
const connectionData = {
|
|
45
43
|
color,
|
|
46
44
|
thickness,
|
|
47
|
-
data:
|
|
45
|
+
data: customData
|
|
48
46
|
};
|
|
49
47
|
const template = tooltipTemplate(connectionData);
|
|
50
48
|
if (!template) {
|
|
@@ -53,6 +51,12 @@ const ConnectionLayerTooltip = (props) => {
|
|
|
53
51
|
if ((0, import_tooltip_type_guards.isDefaultTooltipHandler)(tooltipTemplate)) {
|
|
54
52
|
return template;
|
|
55
53
|
}
|
|
56
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
54
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
55
|
+
import_charts._OverlayTooltip,
|
|
56
|
+
{
|
|
57
|
+
legacyTemplate: template,
|
|
58
|
+
symbolAlignment
|
|
59
|
+
}
|
|
60
|
+
);
|
|
57
61
|
};
|
|
58
62
|
ConnectionLayerTooltip["displayName"] = "ConnectionLayerTooltip";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type GeoJSON from 'geojson';
|
|
2
2
|
import type { Connection, CurvedLine } from '../../../types/connection-layer.js';
|
|
3
|
-
export declare const parseConnectionDataToGeoJSON: <T extends Connection>(data: T[], thickness: number, color: string | ((connection: T) => string), curve?: CurvedLine) =>
|
|
3
|
+
export declare const parseConnectionDataToGeoJSON: <T extends Connection>(data: T[], thickness: number, color: string | ((connection: T) => string), curve?: CurvedLine) => {
|
|
4
|
+
geoJson: GeoJSON.FeatureCollection;
|
|
5
|
+
};
|
|
@@ -36,14 +36,11 @@ const getLineThickness = (thickness) => {
|
|
|
36
36
|
}
|
|
37
37
|
return thickness;
|
|
38
38
|
};
|
|
39
|
-
const
|
|
40
|
-
const getFeatureProperties = (thickness, curve) => (properties, id) => {
|
|
39
|
+
const getRenderingProperties = (thickness, id, curve) => {
|
|
41
40
|
const lineThickness = getLineThickness(thickness);
|
|
42
41
|
return {
|
|
43
|
-
...properties,
|
|
44
42
|
id,
|
|
45
43
|
__lineWidth: lineThickness,
|
|
46
|
-
__nullValues: getKeysWithNullValues(properties),
|
|
47
44
|
curve
|
|
48
45
|
};
|
|
49
46
|
};
|
|
@@ -54,33 +51,38 @@ const getLineFeature = (path, featureProperties) => {
|
|
|
54
51
|
}
|
|
55
52
|
return (0, import_get_straight_line_feature.getStraightLineFeature)(path, featureProperties);
|
|
56
53
|
};
|
|
54
|
+
const getConnectionColor = (connection, color) => {
|
|
55
|
+
const parsedColor = (0, import_define_color.defineColor)(color, connection);
|
|
56
|
+
const canvasColor = (0, import_charts._getCanvasColor)(parsedColor);
|
|
57
|
+
const hoveredColor = (0, import_calculate_hovered_color.calculateHoveredColor)(canvasColor);
|
|
58
|
+
return {
|
|
59
|
+
__lineColor: canvasColor,
|
|
60
|
+
__lineHoveredColor: hoveredColor
|
|
61
|
+
};
|
|
62
|
+
};
|
|
57
63
|
const getFeatures = (data, thickness, color, curve) => {
|
|
58
|
-
const getProperties = getFeatureProperties(thickness, curve);
|
|
59
64
|
const features = [];
|
|
60
65
|
data.forEach((feature, index) => {
|
|
61
66
|
if (feature.path.length >= 2) {
|
|
62
|
-
const
|
|
67
|
+
const renderingProps = getRenderingProperties(
|
|
68
|
+
thickness,
|
|
69
|
+
`connection-${index}`,
|
|
70
|
+
curve
|
|
71
|
+
);
|
|
63
72
|
const featureProperties = {
|
|
64
|
-
...
|
|
73
|
+
...renderingProps,
|
|
74
|
+
__dataIndex: index,
|
|
65
75
|
...getConnectionColor(feature, color)
|
|
66
76
|
};
|
|
67
|
-
features.push(getLineFeature(path, featureProperties));
|
|
77
|
+
features.push(getLineFeature(feature.path, featureProperties));
|
|
68
78
|
}
|
|
69
79
|
});
|
|
70
80
|
return features;
|
|
71
81
|
};
|
|
72
|
-
const getConnectionColor = (connection, color) => {
|
|
73
|
-
const parsedColor = (0, import_define_color.defineColor)(color, connection);
|
|
74
|
-
const canvasColor = (0, import_charts._getCanvasColor)(parsedColor);
|
|
75
|
-
const hoveredColor = (0, import_calculate_hovered_color.calculateHoveredColor)(canvasColor);
|
|
76
|
-
return {
|
|
77
|
-
__lineColor: canvasColor,
|
|
78
|
-
__lineHoveredColor: hoveredColor
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
82
|
const parseConnectionDataToGeoJSON = (data, thickness, color, curve) => {
|
|
82
|
-
|
|
83
|
+
const geoJson = {
|
|
83
84
|
type: "FeatureCollection",
|
|
84
85
|
features: getFeatures(data, thickness, color, curve)
|
|
85
86
|
};
|
|
87
|
+
return { geoJson };
|
|
86
88
|
};
|
|
@@ -29,6 +29,7 @@ var import_BackgroundSymbolLayer = require("./BackgroundSymbolLayer.js");
|
|
|
29
29
|
var import_DotLayerTooltip = require("./DotLayerTooltip.js");
|
|
30
30
|
var import_parse_dot_data_to_geo_json = require("./utils/parse-dot-data-to-geo-json.js");
|
|
31
31
|
var import_constants = require("../../constants.js");
|
|
32
|
+
var import_use_layer_before_id = require("../../hooks/use-layer-before-id.js");
|
|
32
33
|
var import_use_layer_coloring_strategy = require("../../hooks/use-layer-coloring-strategy.js");
|
|
33
34
|
var import_use_legend_interaction_highlighting = require("../../hooks/use-legend-interaction-highlighting.js");
|
|
34
35
|
var import_use_legend_interaction_visibility = require("../../hooks/use-legend-interaction-visibility.js");
|
|
@@ -68,11 +69,16 @@ const DotLayer = (props) => {
|
|
|
68
69
|
props,
|
|
69
70
|
colorParser
|
|
70
71
|
);
|
|
71
|
-
const
|
|
72
|
+
const {
|
|
73
|
+
handler: tooltipTemplate,
|
|
74
|
+
hidden: tooltipHidden,
|
|
75
|
+
symbolAlignment
|
|
76
|
+
} = (0, import_use_tooltip_template.useTooltipTemplate)(children, import_DotLayerTooltip2.DotLayerTooltip, { extractProps: true });
|
|
72
77
|
const sourceId = `source-${layerId}`;
|
|
73
78
|
(0, import_use_legend_interaction_highlighting.useLegendInteractionHighlighting)(props, sourceId);
|
|
74
79
|
(0, import_use_legend_interaction_visibility.useLegendInteractionVisibility)(props, layerId);
|
|
75
|
-
const
|
|
80
|
+
const beforeId = (0, import_use_layer_before_id.useLayerBeforeId)(layerId);
|
|
81
|
+
const { geoJson: dataGeoJson } = (0, import_parse_dot_data_to_geo_json.parseDotDataToGeoJSON)(
|
|
76
82
|
data,
|
|
77
83
|
shapeColor,
|
|
78
84
|
bearing,
|
|
@@ -85,6 +91,7 @@ const DotLayer = (props) => {
|
|
|
85
91
|
{
|
|
86
92
|
type: "symbol",
|
|
87
93
|
id: layerId,
|
|
94
|
+
beforeId,
|
|
88
95
|
layout: {
|
|
89
96
|
"icon-image": symbolName,
|
|
90
97
|
"icon-size": import_constants.DEFAULT_ICON_SIZE_RATIO,
|
|
@@ -130,7 +137,9 @@ const DotLayer = (props) => {
|
|
|
130
137
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TooltipWrapper.TooltipWrapper, { layerId, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
131
138
|
import_DotLayerTooltip.DotLayerTooltip,
|
|
132
139
|
{
|
|
133
|
-
tooltipTemplate: (0, import_tooltip_type_guards.isDotTooltipTemplate)(tooltipTemplate) ? tooltipTemplate : void 0
|
|
140
|
+
tooltipTemplate: (0, import_tooltip_type_guards.isDotTooltipTemplate)(tooltipTemplate) ? tooltipTemplate : void 0,
|
|
141
|
+
hidden: tooltipHidden,
|
|
142
|
+
symbolAlignment
|
|
134
143
|
}
|
|
135
144
|
) })
|
|
136
145
|
] });
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { DotLayerTooltipHandler } from '../../types/tooltip.js';
|
|
2
2
|
export interface DotLayerTooltipProps {
|
|
3
3
|
tooltipTemplate?: DotLayerTooltipHandler;
|
|
4
|
+
hidden?: boolean;
|
|
5
|
+
symbolAlignment?: 'left' | 'right';
|
|
4
6
|
}
|
|
5
7
|
export declare const DotLayerTooltip: {
|
|
6
8
|
(props: DotLayerTooltipProps): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -26,9 +26,9 @@ var import_charts = require("@dynatrace/strato-components/charts");
|
|
|
26
26
|
var import_use_geo_layer_tooltip = require("../../hooks/use-geo-layer-tooltip.js");
|
|
27
27
|
var import_tooltip_type_guards = require("../../utils/tooltip-type-guards.js");
|
|
28
28
|
const DotLayerTooltip = (props) => {
|
|
29
|
-
const { tooltipTemplate } = props;
|
|
29
|
+
const { tooltipTemplate, hidden, symbolAlignment } = props;
|
|
30
30
|
const { data, inBounds, position } = (0, import_use_geo_layer_tooltip.useGeoLayerTooltip)("geoDot");
|
|
31
|
-
if (!tooltipTemplate || !inBounds || !position) {
|
|
31
|
+
if (hidden || !tooltipTemplate || !inBounds || !position) {
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
34
|
if (!data || !data[0]) {
|
|
@@ -47,6 +47,12 @@ const DotLayerTooltip = (props) => {
|
|
|
47
47
|
if ((0, import_tooltip_type_guards.isDefaultTooltipHandler)(tooltipTemplate)) {
|
|
48
48
|
return template;
|
|
49
49
|
}
|
|
50
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
51
|
+
import_charts._OverlayTooltip,
|
|
52
|
+
{
|
|
53
|
+
legacyTemplate: template,
|
|
54
|
+
symbolAlignment
|
|
55
|
+
}
|
|
56
|
+
);
|
|
51
57
|
};
|
|
52
58
|
DotLayerTooltip["displayName"] = "DotLayerTooltip";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type GeoJSON from 'geojson';
|
|
2
2
|
import type { Location } from '../../../types/location.js';
|
|
3
|
-
export declare const parseDotDataToGeoJSON: <T extends Location>(data: T[], color: string | ((item: T) => string), bearing: number | ((item: T) => number), backgroundColor: boolean | string | ((item: T) => string)) =>
|
|
3
|
+
export declare const parseDotDataToGeoJSON: <T extends Location>(data: T[], color: string | ((item: T) => string), bearing: number | ((item: T) => number), backgroundColor: boolean | string | ((item: T) => string)) => {
|
|
4
|
+
geoJson: GeoJSON.FeatureCollection;
|
|
5
|
+
};
|
|
@@ -27,18 +27,17 @@ var import_resolve_icon_background = require("./resolve-icon-background.js");
|
|
|
27
27
|
var import_calculate_hovered_color = require("../../../utils/calculate-hovered-color.js");
|
|
28
28
|
var import_define_color = require("../../../utils/define-color.js");
|
|
29
29
|
const parseDotDataToGeoJSON = (data, color, bearing, backgroundColor) => {
|
|
30
|
-
|
|
30
|
+
const geoJson = {
|
|
31
31
|
type: "FeatureCollection",
|
|
32
|
-
features: data.map((feature) => {
|
|
33
|
-
const { longitude, latitude
|
|
32
|
+
features: data.map((feature, index) => {
|
|
33
|
+
const { longitude, latitude } = feature;
|
|
34
34
|
const canvasColor = (0, import_charts._getCanvasColor)((0, import_define_color.defineColor)(color, feature));
|
|
35
35
|
const hoveredColor = (0, import_calculate_hovered_color.calculateHoveredColor)(canvasColor);
|
|
36
36
|
const { parsedBackgroundColor, parsedHoveredBackgroundColor } = (0, import_resolve_icon_background.resolveIconBackground)(feature, backgroundColor);
|
|
37
37
|
return {
|
|
38
38
|
type: "Feature",
|
|
39
39
|
properties: {
|
|
40
|
-
|
|
41
|
-
...properties,
|
|
40
|
+
__dataIndex: index,
|
|
42
41
|
__color: canvasColor,
|
|
43
42
|
__hoveredColor: hoveredColor,
|
|
44
43
|
__backgroundColor: parsedBackgroundColor,
|
|
@@ -49,4 +48,5 @@ const parseDotDataToGeoJSON = (data, color, bearing, backgroundColor) => {
|
|
|
49
48
|
};
|
|
50
49
|
})
|
|
51
50
|
};
|
|
51
|
+
return { geoJson };
|
|
52
52
|
};
|
|
@@ -38,9 +38,9 @@ var import_use_map_base_layer_features = require("../hooks/use-map-base-layer-fe
|
|
|
38
38
|
var import_use_map_config = require("../hooks/use-map-config.js");
|
|
39
39
|
var import_use_map_loading = require("../hooks/use-map-loading.js");
|
|
40
40
|
var import_use_map_performance = require("../hooks/use-map-performance.js");
|
|
41
|
+
var import_use_map_runtime_error = require("../hooks/use-map-runtime-error.js");
|
|
41
42
|
var import_use_overlay_events = require("../hooks/use-overlay-events.js");
|
|
42
43
|
var import_use_tooltip_event_listeners = require("../hooks/use-tooltip-event-listeners.js");
|
|
43
|
-
var import_use_webgl_context_error = require("../hooks/use-webgl-context-error.js");
|
|
44
44
|
var import_default_style = require("../map-styles/default-style.js");
|
|
45
45
|
var import_imperative_handler_provider = require("../providers/imperative-handler.provider.js");
|
|
46
46
|
var import_get_color_from_token = require("../utils/get-color-from-token.js");
|
|
@@ -93,21 +93,23 @@ const MapSource = () => {
|
|
|
93
93
|
};
|
|
94
94
|
const MapInteractions = ({
|
|
95
95
|
children,
|
|
96
|
-
onContextLostError
|
|
96
|
+
onContextLostError,
|
|
97
|
+
interactiveLayerIds
|
|
97
98
|
}) => {
|
|
98
|
-
const [
|
|
99
|
-
(0,
|
|
100
|
-
(0, import_use_active_interaction.useActiveInteraction)();
|
|
101
|
-
(0, import_use_webgl_context_error.useWebGLContextError)(() => {
|
|
99
|
+
const [runtimeError, setRuntimeError] = (0, import_react.useState)(null);
|
|
100
|
+
const onRuntimeError = (0, import_react.useCallback)(() => {
|
|
102
101
|
onContextLostError?.();
|
|
103
|
-
|
|
102
|
+
setRuntimeError(
|
|
104
103
|
new Error(
|
|
105
|
-
"
|
|
104
|
+
"The map encountered repeated rendering errors and could not recover. Please reload the page."
|
|
106
105
|
)
|
|
107
106
|
);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
}, [onContextLostError]);
|
|
108
|
+
(0, import_use_hover_interaction.useHoverInteraction)(interactiveLayerIds);
|
|
109
|
+
(0, import_use_active_interaction.useActiveInteraction)(interactiveLayerIds);
|
|
110
|
+
(0, import_use_map_runtime_error.useMapRuntimeError)({ onError: onRuntimeError });
|
|
111
|
+
if (runtimeError) {
|
|
112
|
+
throw runtimeError;
|
|
111
113
|
}
|
|
112
114
|
return children;
|
|
113
115
|
};
|
|
@@ -234,7 +236,14 @@ const MapContent = (0, import_react.forwardRef)((props, forwardedRef) => {
|
|
|
234
236
|
children: [
|
|
235
237
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MapSource, {}),
|
|
236
238
|
loading ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
237
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
239
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
240
|
+
MapInteractions,
|
|
241
|
+
{
|
|
242
|
+
onContextLostError,
|
|
243
|
+
interactiveLayerIds: layerIds,
|
|
244
|
+
children
|
|
245
|
+
}
|
|
246
|
+
),
|
|
238
247
|
shouldRenderToolbar ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MapToolbar.MapToolbar, {}) : null
|
|
239
248
|
] })
|
|
240
249
|
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var geo_data_lookup_context_exports = {};
|
|
20
|
+
__export(geo_data_lookup_context_exports, {
|
|
21
|
+
GeoDataLookupContext: () => GeoDataLookupContext
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(geo_data_lookup_context_exports);
|
|
24
|
+
var import_react = require("react");
|
|
25
|
+
const GeoDataLookupContext = (0, import_react.createContext)(
|
|
26
|
+
/* @__PURE__ */ new Map()
|
|
27
|
+
);
|
|
@@ -16,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var map_view_provider_context_exports = {};
|
|
20
|
+
__export(map_view_provider_context_exports, {
|
|
21
|
+
MapViewProviderContext: () => MapViewProviderContext
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
var
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
module.exports = __toCommonJS(map_view_provider_context_exports);
|
|
24
|
+
var import_react = require("react");
|
|
25
|
+
const MapViewProviderContext = (0, import_react.createContext)({
|
|
26
|
+
countryCode: void 0,
|
|
27
|
+
displayWorldMap: void 0
|
|
28
28
|
});
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Handles click-to-activate interactions on map features.
|
|
3
|
+
*
|
|
4
|
+
* Scopes `queryRenderedFeatures` to `interactiveLayerIds` to prevent accidental
|
|
5
|
+
* activation of base/background layers. Both query calls are try-caught to
|
|
6
|
+
* contain maplibre-gl runtime errors without crashing the component tree.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useActiveInteraction: (interactiveLayerIds: string[]) => void;
|
|
@@ -24,32 +24,45 @@ module.exports = __toCommonJS(use_active_interaction_exports);
|
|
|
24
24
|
var import_react_maplibre = require("@vis.gl/react-maplibre");
|
|
25
25
|
var import_lodash_es = require("lodash");
|
|
26
26
|
var import_react = require("react");
|
|
27
|
-
var import_constants = require("../constants.js");
|
|
28
27
|
var import_get_min_value_feature = require("../utils/get-min-value-feature.js");
|
|
29
|
-
const useActiveInteraction = () => {
|
|
28
|
+
const useActiveInteraction = (interactiveLayerIds) => {
|
|
30
29
|
const map = (0, import_react_maplibre.useMap)().current;
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const featureIdRef = (0, import_react.useRef)(void 0);
|
|
31
|
+
const sourceIdRef = (0, import_react.useRef)(void 0);
|
|
32
|
+
const interactiveLayerIdsRef = (0, import_react.useRef)(interactiveLayerIds);
|
|
33
|
+
interactiveLayerIdsRef.current = interactiveLayerIds;
|
|
33
34
|
const handleClick = (0, import_react.useCallback)(
|
|
34
35
|
({ point }) => {
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
let features = [];
|
|
37
|
+
try {
|
|
38
|
+
features = map.queryRenderedFeatures(point, {
|
|
39
|
+
layers: interactiveLayerIdsRef.current
|
|
40
|
+
});
|
|
41
|
+
} catch {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let allFeatures = [];
|
|
45
|
+
try {
|
|
46
|
+
allFeatures = map.queryRenderedFeatures(void 0, {
|
|
47
|
+
layers: interactiveLayerIdsRef.current
|
|
48
|
+
});
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
37
51
|
const layerId = features?.[0]?.layer?.id;
|
|
38
52
|
const hasHoveredFeatures = !(0, import_lodash_es.isNil)(features) && features.length > 0 && !(0, import_lodash_es.isUndefined)(layerId);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!(0, import_lodash_es.isUndefined)(featureId) && !(0, import_lodash_es.isUndefined)(sourceId)) {
|
|
53
|
+
if (hasHoveredFeatures) {
|
|
54
|
+
if (!(0, import_lodash_es.isUndefined)(featureIdRef.current) && !(0, import_lodash_es.isUndefined)(sourceIdRef.current)) {
|
|
42
55
|
map.setFeatureState(
|
|
43
|
-
{ source:
|
|
56
|
+
{ source: sourceIdRef.current, id: featureIdRef.current },
|
|
44
57
|
{ active: false }
|
|
45
58
|
);
|
|
46
59
|
}
|
|
47
60
|
const minFeature = (0, import_get_min_value_feature.getMinValueFeature)(features);
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
featureIdRef.current = minFeature.id;
|
|
62
|
+
sourceIdRef.current = minFeature.layer.source;
|
|
50
63
|
const activeState = features[0].state.active;
|
|
51
64
|
map.setFeatureState(
|
|
52
|
-
{ source:
|
|
65
|
+
{ source: sourceIdRef.current, id: featureIdRef.current },
|
|
53
66
|
{ active: !activeState }
|
|
54
67
|
);
|
|
55
68
|
allFeatures.forEach((feature) => {
|
|
@@ -60,46 +73,49 @@ const useActiveInteraction = () => {
|
|
|
60
73
|
);
|
|
61
74
|
}
|
|
62
75
|
});
|
|
63
|
-
} else {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
}
|
|
76
|
+
} else if (!(0, import_lodash_es.isUndefined)(featureIdRef.current) && !(0, import_lodash_es.isUndefined)(sourceIdRef.current)) {
|
|
77
|
+
map.setFeatureState(
|
|
78
|
+
{ source: sourceIdRef.current, id: featureIdRef.current },
|
|
79
|
+
{ active: false }
|
|
80
|
+
);
|
|
81
|
+
allFeatures.forEach((feature) => {
|
|
82
|
+
if (feature.id !== void 0 && feature.layer.source !== void 0) {
|
|
83
|
+
map.setFeatureState(
|
|
84
|
+
{ source: feature.layer.source, id: feature.id },
|
|
85
|
+
{ isAnyActive: false }
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
78
89
|
}
|
|
79
90
|
},
|
|
80
|
-
[
|
|
91
|
+
[map]
|
|
81
92
|
);
|
|
82
93
|
const onEscapeKeyPressedHandler = (0, import_react.useCallback)(
|
|
83
94
|
(event) => {
|
|
84
95
|
if (event.key === "Escape") {
|
|
85
|
-
if (!(0, import_lodash_es.isUndefined)(
|
|
96
|
+
if (!(0, import_lodash_es.isUndefined)(featureIdRef.current) && !(0, import_lodash_es.isUndefined)(sourceIdRef.current)) {
|
|
86
97
|
map.setFeatureState(
|
|
87
|
-
{ source:
|
|
98
|
+
{ source: sourceIdRef.current, id: featureIdRef.current },
|
|
88
99
|
{ active: false }
|
|
89
100
|
);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
try {
|
|
102
|
+
const allFeatures = map.queryRenderedFeatures(void 0, {
|
|
103
|
+
layers: interactiveLayerIdsRef.current
|
|
104
|
+
});
|
|
105
|
+
allFeatures.forEach((feature) => {
|
|
106
|
+
if (feature.id !== void 0 && feature.layer.source !== void 0) {
|
|
107
|
+
map.setFeatureState(
|
|
108
|
+
{ source: feature.layer.source, id: feature.id },
|
|
109
|
+
{ isAnyActive: false }
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
99
115
|
}
|
|
100
116
|
}
|
|
101
117
|
},
|
|
102
|
-
[
|
|
118
|
+
[map]
|
|
103
119
|
);
|
|
104
120
|
(0, import_react.useEffect)(() => {
|
|
105
121
|
map.on("click", handleClick);
|
|
@@ -108,5 +124,5 @@ const useActiveInteraction = () => {
|
|
|
108
124
|
map.off("click", handleClick);
|
|
109
125
|
window.removeEventListener("keyup", onEscapeKeyPressedHandler);
|
|
110
126
|
};
|
|
111
|
-
}, []);
|
|
127
|
+
}, [map, handleClick, onEscapeKeyPressedHandler]);
|
|
112
128
|
};
|
|
@@ -31,6 +31,7 @@ var import_attach_image_to_map = require("../utils/attach-image-to-map.js");
|
|
|
31
31
|
var import_create_bitmap_config_options = require("../utils/create-bitmap-config-options.js");
|
|
32
32
|
var import_get_data_uri = require("../utils/get-data-uri.js");
|
|
33
33
|
var import_get_scaled_symbol_size = require("../utils/get-scaled-symbol-size.js");
|
|
34
|
+
var import_is_browser_firefox = require("../utils/is-browser-firefox.js");
|
|
34
35
|
const useAttachImageFromIcon = (icon, suffix, outputSize) => {
|
|
35
36
|
const { elementAsString, ref } = (0, import_use_safe_svg_parser.useSafeSvgParser)();
|
|
36
37
|
const defaultScaledIconSize = (0, import_get_scaled_symbol_size.getScaledSymbolSize)();
|
|
@@ -48,14 +49,15 @@ const useAttachImageFromIcon = (icon, suffix, outputSize) => {
|
|
|
48
49
|
fakeDomContainer.remove();
|
|
49
50
|
const stringUrl = (0, import_get_data_uri.getDataUri)(elementAsString);
|
|
50
51
|
img.addEventListener("load", () => {
|
|
51
|
-
createImageBitmap(
|
|
52
|
+
const bitmapPromise = (0, import_is_browser_firefox.isFirefox)() ? createImageBitmap(img, (0, import_create_bitmap_config_options.createBitmapConfigOptions)(outputSize)) : createImageBitmap(
|
|
52
53
|
img,
|
|
53
54
|
0,
|
|
54
55
|
0,
|
|
55
56
|
import_constants.DEFAULT_INPUT_ICON_SIZE,
|
|
56
57
|
import_constants.DEFAULT_INPUT_ICON_SIZE,
|
|
57
58
|
(0, import_create_bitmap_config_options.createBitmapConfigOptions)(outputSize)
|
|
58
|
-
)
|
|
59
|
+
);
|
|
60
|
+
bitmapPromise.then((bitmap) => {
|
|
59
61
|
if (!map) {
|
|
60
62
|
return;
|
|
61
63
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Sets and removes hovered state to the features depending on mouse position
|
|
2
|
+
* Sets and removes hovered state to the features depending on mouse position.
|
|
3
|
+
*
|
|
4
|
+
* @param interactiveLayerIds - maplibre-gl layer IDs to scope the feature query.
|
|
5
|
+
* Scoping to data layers prevents touching base-map vector tiles whose internal
|
|
6
|
+
* feature index may be in a transitional state (root cause of APPDEV-17854).
|
|
3
7
|
*/
|
|
4
|
-
export declare const useHoverInteraction: () => void;
|
|
8
|
+
export declare const useHoverInteraction: (interactiveLayerIds: string[]) => void;
|