@dynatrace/strato-geo 3.6.0 → 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 +4 -1
- package/esm/map/components/BubbleLayer/BubbleLayer.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 +5 -2
- package/esm/map/components/ChoroplethLayer/ChoroplethLayer.js.map +2 -2
- 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 +1 -1
- 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 +7 -9
- 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 +4 -1
- package/esm/map/components/DotLayer/DotLayer.js.map +2 -2
- 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/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-map-runtime-error.js +93 -0
- package/esm/map/hooks/use-map-runtime-error.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-webgl-context-error.js +2 -1
- package/esm/map/hooks/use-webgl-context-error.js.map +2 -2
- package/esm/map/index.js.map +1 -1
- package/esm/map/slots/Tooltip.js.map +2 -2
- 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/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 +4 -1
- 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 +5 -2
- 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 +1 -1
- package/map/components/ConnectionLayer/ConnectionLayerLine.js +3 -0
- package/map/components/ConnectionLayer/ConnectionLayerTooltip.js +7 -9
- 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 +4 -1
- 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/{components/ConnectionLayer/utils/restore-null-props.js → contexts/geo-data-lookup.context.js} +8 -9
- 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-map-runtime-error.d.ts +34 -0
- package/map/hooks/use-map-runtime-error.js +112 -0
- package/map/hooks/use-overlay-events.js +11 -2
- package/map/hooks/use-webgl-context-error.js +2 -1
- package/map/slots/Tooltip.d.ts +2 -0
- package/map/types/connection-layer.d.ts +1 -8
- package/map/types/tooltip.d.ts +1 -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/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
|
@@ -28,6 +28,7 @@ var import_ChoroplethLayerTooltip = require("./ChoroplethLayerTooltip.js");
|
|
|
28
28
|
var import_ChoroplethOutlineLayer = require("./ChoroplethOutlineLayer.js");
|
|
29
29
|
var import_parse_region_data_to_geo_json = require("./utils/parse-region-data-to-geo-json.js");
|
|
30
30
|
var import_constants = require("../../constants.js");
|
|
31
|
+
var import_use_layer_before_id = require("../../hooks/use-layer-before-id.js");
|
|
31
32
|
var import_use_layer_coloring_strategy = require("../../hooks/use-layer-coloring-strategy.js");
|
|
32
33
|
var import_use_legend_interaction_highlighting = require("../../hooks/use-legend-interaction-highlighting.js");
|
|
33
34
|
var import_use_legend_interaction_visibility = require("../../hooks/use-legend-interaction-visibility.js");
|
|
@@ -50,7 +51,8 @@ const ChoroplethLayer = (props) => {
|
|
|
50
51
|
const sourceId = layerId.replace("layer", "source");
|
|
51
52
|
(0, import_use_legend_interaction_highlighting.useLegendInteractionHighlighting)(props, sourceId);
|
|
52
53
|
(0, import_use_legend_interaction_visibility.useLegendInteractionVisibility)(props, layerId);
|
|
53
|
-
const
|
|
54
|
+
const beforeId = (0, import_use_layer_before_id.useLayerBeforeId)(layerId);
|
|
55
|
+
const dataGeoJSON = mapSource ? (0, import_parse_region_data_to_geo_json.parseRegionDataToGeoJSON)(mapSource, data, regionAccessor, choroplethColor).geoJson : void 0;
|
|
54
56
|
const {
|
|
55
57
|
handler: tooltipTemplate,
|
|
56
58
|
hidden: tooltipHidden,
|
|
@@ -65,6 +67,7 @@ const ChoroplethLayer = (props) => {
|
|
|
65
67
|
id: layerId,
|
|
66
68
|
source: sourceId,
|
|
67
69
|
type: "fill",
|
|
70
|
+
beforeId,
|
|
68
71
|
paint: {
|
|
69
72
|
"fill-color": ["get", "__color"],
|
|
70
73
|
"fill-opacity": [
|
|
@@ -85,7 +88,7 @@ const ChoroplethLayer = (props) => {
|
|
|
85
88
|
...behavioralTrackingProps
|
|
86
89
|
}
|
|
87
90
|
),
|
|
88
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ChoroplethOutlineLayer.ChoroplethOutlineLayer, { sourceId }),
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ChoroplethOutlineLayer.ChoroplethOutlineLayer, { sourceId, beforeId }),
|
|
89
92
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TooltipWrapper.TooltipWrapper, { layerId, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
90
93
|
import_ChoroplethLayerTooltip.ChoroplethLayerTooltip,
|
|
91
94
|
{
|
|
@@ -26,7 +26,7 @@ var import_react_maplibre = require("@vis.gl/react-maplibre");
|
|
|
26
26
|
var import_charts = require("@dynatrace/strato-components/charts");
|
|
27
27
|
var import_constants = require("../../constants.js");
|
|
28
28
|
const ChoroplethOutlineLayer = (props) => {
|
|
29
|
-
const { sourceId } = props;
|
|
29
|
+
const { sourceId, beforeId } = props;
|
|
30
30
|
const activeColor = (0, import_charts._getCanvasColor)(import_constants.ACTIVE_COLOR);
|
|
31
31
|
const defaultBoundariesBorderColor = (0, import_charts._getCanvasColor)(
|
|
32
32
|
import_constants.DEFAULT_BOUNDARIES_BORDER_COLOR
|
|
@@ -38,6 +38,7 @@ const ChoroplethOutlineLayer = (props) => {
|
|
|
38
38
|
{
|
|
39
39
|
source: sourceId,
|
|
40
40
|
type: "line",
|
|
41
|
+
beforeId,
|
|
41
42
|
paint: {
|
|
42
43
|
"line-color": [
|
|
43
44
|
"case",
|
|
@@ -65,6 +66,7 @@ const ChoroplethOutlineLayer = (props) => {
|
|
|
65
66
|
{
|
|
66
67
|
source: sourceId,
|
|
67
68
|
type: "line",
|
|
69
|
+
beforeId,
|
|
68
70
|
paint: {
|
|
69
71
|
"line-color": [
|
|
70
72
|
"case",
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type GeoJSON from 'geojson';
|
|
2
|
-
export declare const parseRegionDataToGeoJSON: <T extends Record<string, unknown>>(mapSource: GeoJSON.FeatureCollection, data: T[], regionAccessor: string | ((i: T) => string), color: string | ((i: T) => string)) =>
|
|
2
|
+
export declare const parseRegionDataToGeoJSON: <T extends Record<string, unknown>>(mapSource: GeoJSON.FeatureCollection, data: T[], regionAccessor: string | ((i: T) => string), color: string | ((i: T) => string)) => {
|
|
3
|
+
geoJson: GeoJSON.FeatureCollection;
|
|
4
|
+
};
|
|
@@ -26,7 +26,7 @@ var import_core = require("@dynatrace/strato-components/core");
|
|
|
26
26
|
var import_calculate_hovered_color = require("../../../utils/calculate-hovered-color.js");
|
|
27
27
|
var import_define_color = require("../../../utils/define-color.js");
|
|
28
28
|
const parseRegionDataToGeoJSON = (mapSource, data, regionAccessor, color) => {
|
|
29
|
-
const features = data.reduce((features2, item) => {
|
|
29
|
+
const features = data.reduce((features2, item, index) => {
|
|
30
30
|
let id = "";
|
|
31
31
|
if (typeof regionAccessor === "function") {
|
|
32
32
|
id = regionAccessor(item);
|
|
@@ -44,8 +44,7 @@ const parseRegionDataToGeoJSON = (mapSource, data, regionAccessor, color) => {
|
|
|
44
44
|
properties: {
|
|
45
45
|
name,
|
|
46
46
|
region_type,
|
|
47
|
-
|
|
48
|
-
...item,
|
|
47
|
+
__dataIndex: index,
|
|
49
48
|
__color: canvasColor,
|
|
50
49
|
__hoveredColor: hoveredColor
|
|
51
50
|
}
|
|
@@ -55,7 +54,9 @@ const parseRegionDataToGeoJSON = (mapSource, data, regionAccessor, color) => {
|
|
|
55
54
|
return features2;
|
|
56
55
|
}, []);
|
|
57
56
|
return {
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
geoJson: {
|
|
58
|
+
type: "FeatureCollection",
|
|
59
|
+
features
|
|
60
|
+
}
|
|
60
61
|
};
|
|
61
62
|
};
|
|
@@ -56,7 +56,7 @@ const ConnectionLayer = (props) => {
|
|
|
56
56
|
const sourceId = `source-${layerId}`;
|
|
57
57
|
(0, import_use_legend_interaction_highlighting.useLegendInteractionHighlighting)(props, sourceId);
|
|
58
58
|
(0, import_use_legend_interaction_visibility.useLegendInteractionVisibility)(props, layerId);
|
|
59
|
-
const geoJsonData = (0, import_parse_connection_data_to_geo_json.parseConnectionDataToGeoJSON)(
|
|
59
|
+
const { geoJson: geoJsonData } = (0, import_parse_connection_data_to_geo_json.parseConnectionDataToGeoJSON)(
|
|
60
60
|
data,
|
|
61
61
|
thickness,
|
|
62
62
|
connectionColor,
|
|
@@ -25,15 +25,18 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
25
25
|
var import_react_maplibre = require("@vis.gl/react-maplibre");
|
|
26
26
|
var import_core = require("@dynatrace/strato-components/core");
|
|
27
27
|
var import_constants = require("../../constants.js");
|
|
28
|
+
var import_use_layer_before_id = require("../../hooks/use-layer-before-id.js");
|
|
28
29
|
const ConnectionLayerLine = (props) => {
|
|
29
30
|
const { geoJsonData, layerId, sourceId, line, children, ...restProps } = props;
|
|
30
31
|
const [behavioralTrackingProps] = (0, import_core._useBehavioralTrackingProps)(restProps);
|
|
32
|
+
const beforeId = (0, import_use_layer_before_id.useLayerBeforeId)(layerId);
|
|
31
33
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_maplibre.Source, { id: sourceId, type: "geojson", data: geoJsonData, promoteId: "id", children: [
|
|
32
34
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
33
35
|
import_react_maplibre.Layer,
|
|
34
36
|
{
|
|
35
37
|
type: "line",
|
|
36
38
|
id: layerId,
|
|
39
|
+
beforeId,
|
|
37
40
|
layout: {
|
|
38
41
|
"line-cap": import_constants.DEFAULT_LINE_CAP,
|
|
39
42
|
"line-join": import_constants.DEFAULT_LINE_JOIN
|
|
@@ -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
29
|
const { tooltipTemplate, hidden, symbolAlignment } = props;
|
|
31
|
-
const {
|
|
32
|
-
data: rawData,
|
|
33
|
-
inBounds,
|
|
34
|
-
position
|
|
35
|
-
} = (0, import_use_geo_layer_tooltip.useGeoLayerTooltip)("geoConnection");
|
|
36
|
-
const data = (0, import_restore_null_props.restoreNullProps)(rawData);
|
|
30
|
+
const { data, inBounds, position } = (0, import_use_geo_layer_tooltip.useGeoLayerTooltip)("geoConnection");
|
|
37
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) {
|
|
@@ -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");
|
|
@@ -76,7 +77,8 @@ const DotLayer = (props) => {
|
|
|
76
77
|
const sourceId = `source-${layerId}`;
|
|
77
78
|
(0, import_use_legend_interaction_highlighting.useLegendInteractionHighlighting)(props, sourceId);
|
|
78
79
|
(0, import_use_legend_interaction_visibility.useLegendInteractionVisibility)(props, layerId);
|
|
79
|
-
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)(
|
|
80
82
|
data,
|
|
81
83
|
shapeColor,
|
|
82
84
|
bearing,
|
|
@@ -89,6 +91,7 @@ const DotLayer = (props) => {
|
|
|
89
91
|
{
|
|
90
92
|
type: "symbol",
|
|
91
93
|
id: layerId,
|
|
94
|
+
beforeId,
|
|
92
95
|
layout: {
|
|
93
96
|
"icon-image": symbolName,
|
|
94
97
|
"icon-size": import_constants.DEFAULT_ICON_SIZE_RATIO,
|
|
@@ -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
|
]
|
|
@@ -16,13 +16,12 @@ 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
|
-
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(restore_null_props_exports);
|
|
24
|
-
var import_lodash_es = require("lodash");
|
|
25
|
-
const restoreNullProps = (data) => data?.map(({ __nullValues, ...rest }) => {
|
|
26
|
-
const nullProps = __nullValues?.map((prop) => ({ [prop]: null })) || [];
|
|
27
|
-
return (0, import_lodash_es.merge)(rest, ...nullProps);
|
|
19
|
+
var geo_data_lookup_context_exports = {};
|
|
20
|
+
__export(geo_data_lookup_context_exports, {
|
|
21
|
+
GeoDataLookupContext: () => GeoDataLookupContext
|
|
28
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
|
+
);
|
|
@@ -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;
|