@dynatrace/strato-geo 3.7.1 → 3.9.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/CHANGELOG.md +2087 -0
- package/esm/map/components/BubbleLayer/BubbleLayerTooltip.js +1 -7
- package/esm/map/components/BubbleLayer/BubbleLayerTooltip.js.map +2 -2
- package/esm/map/components/ChoroplethLayer/ChoroplethLayerTooltip.js +1 -7
- package/esm/map/components/ChoroplethLayer/ChoroplethLayerTooltip.js.map +2 -2
- package/esm/map/components/ConnectionLayer/ConnectionLayerTooltip.js +1 -7
- package/esm/map/components/ConnectionLayer/ConnectionLayerTooltip.js.map +2 -2
- package/esm/map/components/DotLayer/DotLayerTooltip.js +1 -7
- package/esm/map/components/DotLayer/DotLayerTooltip.js.map +2 -2
- package/esm/map/components/toolbar/MapToolbar.js +1 -1
- package/esm/map/components/toolbar/MapToolbar.js.map +1 -1
- package/esm/map/hooks/use-active-interaction.js +35 -20
- package/esm/map/hooks/use-active-interaction.js.map +2 -2
- package/esm/map/hooks/use-attach-symbol-to-map.js +7 -7
- package/esm/map/hooks/use-attach-symbol-to-map.js.map +2 -2
- package/esm/map/hooks/use-hover-interaction.js +12 -0
- package/esm/map/hooks/use-hover-interaction.js.map +2 -2
- package/esm/map/hooks/use-map-runtime-error.js +2 -1
- package/esm/map/hooks/use-map-runtime-error.js.map +2 -2
- package/esm/map/hooks/use-overlay-events.js +27 -15
- package/esm/map/hooks/use-overlay-events.js.map +2 -2
- package/esm/map/utils/get-scaled-symbol-size.js +1 -1
- package/esm/map/utils/get-scaled-symbol-size.js.map +2 -2
- package/lang/uncompiled/en.json +16 -16
- package/map/components/BubbleLayer/BubbleLayerTooltip.js +1 -7
- package/map/components/ChoroplethLayer/ChoroplethLayerTooltip.js +1 -7
- package/map/components/ConnectionLayer/ConnectionLayerTooltip.js +1 -7
- package/map/components/DotLayer/DotLayerTooltip.js +1 -7
- package/map/components/toolbar/MapToolbar.js +1 -1
- package/map/hooks/use-active-interaction.js +35 -20
- package/map/hooks/use-attach-symbol-to-map.d.ts +1 -1
- package/map/hooks/use-attach-symbol-to-map.js +6 -6
- package/map/hooks/use-hover-interaction.js +12 -0
- package/map/hooks/use-map-runtime-error.js +2 -1
- package/map/hooks/use-overlay-events.js +26 -14
- package/map/types/map-view-provider.d.ts +1 -1
- package/map/utils/get-scaled-symbol-size.js +1 -1
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/map/hooks/use-overlay-events.ts"],
|
|
4
|
-
"sourcesContent": ["import type { MapLayerMouseEvent } from 'maplibre-gl';\nimport { useContext } from 'react';\n\nimport {\n _useOverlayTooltipReducer as useTooltipReducer,\n _useOverlayTooltipStore as useOverlayTooltipStore,\n _useOverlayChart as useOverlayChart,\n type _OverlayTooltipGeometryTypes as GeometryTypes,\n} from '@dynatrace/strato-components/charts';\n\nimport { GeoDataLookupContext } from '../contexts/geo-data-lookup.context.js';\nimport { useSetStateOverlay, useSetState } from '../store/store.js';\nimport { buildGeoTooltipState } from '../utils/build-geo-tooltip-state.js';\nimport { extractDataFromEvent } from '../utils/parse-tooltip-data.js';\n\nconst layerIdToGeometry = (layerId: string | undefined): GeometryTypes => {\n if (layerId?.includes('bubble')) {\n return 'geoBubble';\n }\n if (layerId?.includes('choropleth')) {\n return 'geoChoropleth';\n }\n if (layerId?.includes('connection')) {\n return 'geoConnection';\n }\n return 'geoDot';\n};\n\nexport const useOverlayEvents = () => {\n const dataLookupRegistry = useContext(GeoDataLookupContext);\n const setOverlayState = useSetStateOverlay();\n const setState = useSetState();\n const dispatch = useTooltipReducer();\n const store = useOverlayTooltipStore();\n const overlay = useOverlayChart();\n\n const getAbsolutePosition = (event: MapLayerMouseEvent) => {\n return {\n x: Math.round(event.originalEvent.clientX),\n y: Math.round(event.originalEvent.clientY),\n };\n };\n\n const setTooltipMarker = (\n hoveredLayerId: string | undefined,\n location: { lng: number; lat: number } | undefined,\n ) => {\n setState((prev) => ({\n ...prev,\n tooltip: {\n ...prev.tooltip,\n hoveredLayerId,\n location: location as typeof prev.tooltip.location,\n },\n }));\n };\n\n const hideTooltip = () => {\n dispatch({ type: 'RESET_TOOLTIP' })();\n setTooltipMarker(undefined, undefined);\n
|
|
5
|
-
"mappings": "AACA,SAAS,
|
|
4
|
+
"sourcesContent": ["import type { MapLayerMouseEvent } from 'maplibre-gl';\nimport { useContext, useRef } from 'react';\n\nimport {\n _useOverlayTooltipReducer as useTooltipReducer,\n _useOverlayTooltipStore as useOverlayTooltipStore,\n _useOverlayChart as useOverlayChart,\n type _OverlayTooltipGeometryTypes as GeometryTypes,\n} from '@dynatrace/strato-components/charts';\n\nimport { GeoDataLookupContext } from '../contexts/geo-data-lookup.context.js';\nimport { useSetStateOverlay, useSetState } from '../store/store.js';\nimport { buildGeoTooltipState } from '../utils/build-geo-tooltip-state.js';\nimport { extractDataFromEvent } from '../utils/parse-tooltip-data.js';\n\nconst layerIdToGeometry = (layerId: string | undefined): GeometryTypes => {\n if (layerId?.includes('bubble')) {\n return 'geoBubble';\n }\n if (layerId?.includes('choropleth')) {\n return 'geoChoropleth';\n }\n if (layerId?.includes('connection')) {\n return 'geoConnection';\n }\n return 'geoDot';\n};\n\nexport const useOverlayEvents = () => {\n const dataLookupRegistry = useContext(GeoDataLookupContext);\n const setOverlayState = useSetStateOverlay();\n const setState = useSetState();\n const dispatch = useTooltipReducer();\n const store = useOverlayTooltipStore();\n const overlay = useOverlayChart();\n const pinnedFeatureIdRef = useRef<string | undefined>(undefined);\n\n const getAbsolutePosition = (event: MapLayerMouseEvent) => {\n return {\n x: Math.round(event.originalEvent.clientX),\n y: Math.round(event.originalEvent.clientY),\n };\n };\n\n const setTooltipMarker = (\n hoveredLayerId: string | undefined,\n location: { lng: number; lat: number } | undefined,\n ) => {\n setState((prev) => ({\n ...prev,\n tooltip: {\n ...prev.tooltip,\n hoveredLayerId,\n location: location as typeof prev.tooltip.location,\n },\n }));\n };\n\n const hideTooltip = () => {\n dispatch({ type: 'RESET_TOOLTIP' })();\n setTooltipMarker(undefined, undefined);\n pinnedFeatureIdRef.current = undefined;\n };\n\n const showHoverTooltip = (\n event: MapLayerMouseEvent,\n data: unknown[],\n hoveredLayerId: string | undefined,\n ) => {\n overlay.clear();\n\n setTooltipMarker(hoveredLayerId, event.lngLat);\n\n const pos = getAbsolutePosition(event);\n store.setState(\n buildGeoTooltipState({\n absoluteX: pos.x,\n absoluteY: pos.y,\n relativeX: Math.round(event.point.x),\n relativeY: Math.round(event.point.y),\n pinned: false,\n geometry: layerIdToGeometry(hoveredLayerId),\n metadata: data,\n }),\n );\n };\n\n const handleMouseEnter = () => {\n setOverlayState({ mouseInBounds: true });\n };\n\n const handleMouseMove = (event: MapLayerMouseEvent) => {\n if (event.features?.length) {\n const currentState = store.getState();\n\n if (currentState.pinned) {\n return;\n }\n\n const { data, hoveredLayerId } = extractDataFromEvent(\n event,\n dataLookupRegistry,\n );\n\n showHoverTooltip(event, data ?? [], hoveredLayerId);\n } else {\n const currentState = store.getState();\n if (!currentState.pinned) {\n hideTooltip();\n }\n }\n };\n\n const handleMouseLeave = () => {\n setOverlayState({ mouseInBounds: false });\n const currentState = store.getState();\n if (!currentState.pinned) {\n hideTooltip();\n }\n };\n\n const handleMouseClick = (event: MapLayerMouseEvent) => {\n const { data, featureId, hoveredLayerId } = extractDataFromEvent(\n event,\n dataLookupRegistry,\n );\n\n if (!featureId) {\n hideTooltip();\n return;\n }\n\n if (!hoveredLayerId) {\n hideTooltip();\n return;\n }\n\n const currentState = store.getState();\n if (currentState.pinned && pinnedFeatureIdRef.current === featureId) {\n // Unpin and immediately fall back to the hover tooltip so the feature\n // stays described while the pointer is still over it (mirrors the chart\n // OverlayTooltip behaviour on non-touch devices).\n pinnedFeatureIdRef.current = undefined;\n showHoverTooltip(event, data ?? [], hoveredLayerId);\n return;\n }\n\n overlay.clear();\n\n setTooltipMarker(hoveredLayerId, event.lngLat);\n pinnedFeatureIdRef.current = featureId;\n\n const pos = getAbsolutePosition(event);\n store.setState(\n buildGeoTooltipState({\n absoluteX: pos.x,\n absoluteY: pos.y,\n relativeX: Math.round(event.point.x),\n relativeY: Math.round(event.point.y),\n pinned: true,\n geometry: layerIdToGeometry(hoveredLayerId),\n metadata: data,\n }),\n );\n };\n\n const hideTooltipIfNotPinned = () => {\n const currentState = store.getState();\n if (!currentState.pinned) {\n hideTooltip();\n }\n };\n\n return {\n handleMouseEnter,\n handleMouseMove,\n handleMouseLeave,\n handleMouseClick,\n handleZoom: hideTooltipIfNotPinned,\n handleDrag: hideTooltipIfNotPinned,\n };\n};\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,YAAY,cAAc;AAEnC;AAAA,EACE,6BAA6B;AAAA,EAC7B,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA,OAEf;AAEP,SAAS,4BAA4B;AACrC,SAAS,oBAAoB,mBAAmB;AAChD,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AAErC,MAAM,oBAAoB,CAAC,YAA+C;AACxE,MAAI,SAAS,SAAS,QAAQ,GAAG;AAC/B,WAAO;AAAA,EACT;AACA,MAAI,SAAS,SAAS,YAAY,GAAG;AACnC,WAAO;AAAA,EACT;AACA,MAAI,SAAS,SAAS,YAAY,GAAG;AACnC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,MAAM,mBAAmB,MAAM;AACpC,QAAM,qBAAqB,WAAW,oBAAoB;AAC1D,QAAM,kBAAkB,mBAAmB;AAC3C,QAAM,WAAW,YAAY;AAC7B,QAAM,WAAW,kBAAkB;AACnC,QAAM,QAAQ,uBAAuB;AACrC,QAAM,UAAU,gBAAgB;AAChC,QAAM,qBAAqB,OAA2B,MAAS;AAE/D,QAAM,sBAAsB,CAAC,UAA8B;AACzD,WAAO;AAAA,MACL,GAAG,KAAK,MAAM,MAAM,cAAc,OAAO;AAAA,MACzC,GAAG,KAAK,MAAM,MAAM,cAAc,O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SIZE } from "../constants.js";
|
|
2
|
-
const getScaledSymbolSize = (symbolSize = DEFAULT_SYMBOL_SIZE) => symbolSize * devicePixelRatio;
|
|
2
|
+
const getScaledSymbolSize = (symbolSize = DEFAULT_SYMBOL_SIZE) => Math.max(1, symbolSize * devicePixelRatio);
|
|
3
3
|
export {
|
|
4
4
|
getScaledSymbolSize
|
|
5
5
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/map/utils/get-scaled-symbol-size.ts"],
|
|
4
|
-
"sourcesContent": ["import { DEFAULT_SYMBOL_SIZE } from '../constants.js';\n\n/** Scales the icon size by dpr to preserve the size on HiDPI screens */\nexport const getScaledSymbolSize = (symbolSize = DEFAULT_SYMBOL_SIZE) =>\n symbolSize * devicePixelRatio;\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,2BAA2B;AAG7B,MAAM,sBAAsB,CAAC,aAAa,wBAC/C,aAAa;",
|
|
4
|
+
"sourcesContent": ["import { DEFAULT_SYMBOL_SIZE } from '../constants.js';\n\n/** Scales the icon size by dpr to preserve the size on HiDPI screens */\nexport const getScaledSymbolSize = (symbolSize = DEFAULT_SYMBOL_SIZE) =>\n Math.max(1, symbolSize * devicePixelRatio);\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,2BAA2B;AAG7B,MAAM,sBAAsB,CAAC,aAAa,wBAC/C,KAAK,IAAI,GAAG,aAAa,gBAAgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lang/uncompiled/en.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"11eDVd4MkXWk8Bok": {
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"translation": "Zoom in",
|
|
4
|
+
"notes": "Text in a tooltip shown when hovering the \"Zoom in\" action in the geo map chart toolbar"
|
|
5
5
|
},
|
|
6
6
|
"5DTYqeFoXLMaXUHR": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"translation": "Zoom out",
|
|
8
|
+
"notes": "Text in a tooltip shown when hovering the \"Zoom out\" action in the geo map chart toolbar"
|
|
9
9
|
},
|
|
10
10
|
"EhcEZc1+Xc9wYsXg": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"translation": "Zoom to fit",
|
|
12
|
+
"notes": "Text in a tooltip shown when hovering the \"Zoom to fit\" action in the geo map chart toolbar"
|
|
13
13
|
},
|
|
14
14
|
"TXZNTtB5qReH8XE3": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"translation": "Maps have been disabled in your environment - to enable these, please reach out to your environment administrator.",
|
|
16
|
+
"notes": "Message to display when all maps are hidden."
|
|
17
17
|
},
|
|
18
18
|
"g2qESM+ibB5sUyjf": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"translation": "Copy coordinates",
|
|
20
|
+
"notes": "Text in a tooltip shown when hovering a tooltip item and hovering the copy button next to its coordinates"
|
|
21
21
|
},
|
|
22
22
|
"hVE7x0G0Q7/ih93A": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
23
|
+
"translation": "Reset",
|
|
24
|
+
"notes": "Text in a tooltip shown when hovering the \"Reset\" action in the geo map chart toolbar"
|
|
25
25
|
},
|
|
26
26
|
"hlwWx47trlDMOy+V": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
27
|
+
"translation": "Download Data as CSV",
|
|
28
|
+
"notes": "Text in a tooltip shown when hovering the \"Download Data\" action in the geo map chart toolbar"
|
|
29
29
|
},
|
|
30
30
|
"tS7epcIvtrbIhuBy": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
31
|
+
"translation": "An error occurred: Failed to load map data.",
|
|
32
|
+
"notes": "Message to display when an error occurred while getting map data."
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -55,12 +55,6 @@ const BubbleLayerTooltip = (props) => {
|
|
|
55
55
|
if ((0, import_tooltip_type_guards.isDefaultTooltipHandler)(tooltipTemplate)) {
|
|
56
56
|
return template;
|
|
57
57
|
}
|
|
58
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
59
|
-
import_charts._OverlayTooltip,
|
|
60
|
-
{
|
|
61
|
-
legacyTemplate: template,
|
|
62
|
-
symbolAlignment
|
|
63
|
-
}
|
|
64
|
-
);
|
|
58
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_charts._OverlayTooltip, { template, symbolAlignment });
|
|
65
59
|
};
|
|
66
60
|
BubbleLayerTooltip["displayName"] = "BubbleLayerTooltip";
|
|
@@ -47,12 +47,6 @@ const ChoroplethLayerTooltip = (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)(
|
|
51
|
-
import_charts._OverlayTooltip,
|
|
52
|
-
{
|
|
53
|
-
legacyTemplate: template,
|
|
54
|
-
symbolAlignment
|
|
55
|
-
}
|
|
56
|
-
);
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_charts._OverlayTooltip, { template, symbolAlignment });
|
|
57
51
|
};
|
|
58
52
|
ChoroplethLayerTooltip["displayName"] = "ChoroplethLayerTooltip";
|
|
@@ -51,12 +51,6 @@ const ConnectionLayerTooltip = (props) => {
|
|
|
51
51
|
if ((0, import_tooltip_type_guards.isDefaultTooltipHandler)(tooltipTemplate)) {
|
|
52
52
|
return template;
|
|
53
53
|
}
|
|
54
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
55
|
-
import_charts._OverlayTooltip,
|
|
56
|
-
{
|
|
57
|
-
legacyTemplate: template,
|
|
58
|
-
symbolAlignment
|
|
59
|
-
}
|
|
60
|
-
);
|
|
54
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_charts._OverlayTooltip, { template, symbolAlignment });
|
|
61
55
|
};
|
|
62
56
|
ConnectionLayerTooltip["displayName"] = "ConnectionLayerTooltip";
|
|
@@ -47,12 +47,6 @@ 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)(
|
|
51
|
-
import_charts._OverlayTooltip,
|
|
52
|
-
{
|
|
53
|
-
legacyTemplate: template,
|
|
54
|
-
symbolAlignment
|
|
55
|
-
}
|
|
56
|
-
);
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_charts._OverlayTooltip, { template, symbolAlignment });
|
|
57
51
|
};
|
|
58
52
|
DotLayerTooltip["displayName"] = "DotLayerTooltip";
|
|
@@ -86,7 +86,7 @@ const MapToolbar = () => {
|
|
|
86
86
|
initialA11yState: import_constants.initialA11yToolbarTabIndexContext,
|
|
87
87
|
onMouseEnter: handleMouseEnter,
|
|
88
88
|
onMouseLeave: handleMouseLeave,
|
|
89
|
-
menuDisplayMode: "
|
|
89
|
+
menuDisplayMode: "collapsed",
|
|
90
90
|
children: [
|
|
91
91
|
isZoomEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MapZoomInOutButtons.MapZoomInOutButtons, {}),
|
|
92
92
|
isZoomEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MapResetButton.MapResetButton, {}),
|
|
@@ -24,13 +24,38 @@ 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_use_geo_tooltip_sync = require("./use-geo-tooltip-sync.js");
|
|
27
28
|
var import_get_min_value_feature = require("../utils/get-min-value-feature.js");
|
|
28
29
|
const useActiveInteraction = (interactiveLayerIds) => {
|
|
29
30
|
const map = (0, import_react_maplibre.useMap)().current;
|
|
30
31
|
const featureIdRef = (0, import_react.useRef)(void 0);
|
|
31
32
|
const sourceIdRef = (0, import_react.useRef)(void 0);
|
|
33
|
+
const pinnedFromStore = (0, import_use_geo_tooltip_sync.useOverlayTooltipSelector)((state) => state.pinned);
|
|
34
|
+
const prevPinnedRef = (0, import_react.useRef)(false);
|
|
32
35
|
const interactiveLayerIdsRef = (0, import_react.useRef)(interactiveLayerIds);
|
|
33
36
|
interactiveLayerIdsRef.current = interactiveLayerIds;
|
|
37
|
+
const clearActiveFeatureStates = () => {
|
|
38
|
+
if (!(0, import_lodash_es.isUndefined)(featureIdRef.current) && !(0, import_lodash_es.isUndefined)(sourceIdRef.current)) {
|
|
39
|
+
map.setFeatureState(
|
|
40
|
+
{ source: sourceIdRef.current, id: featureIdRef.current },
|
|
41
|
+
{ active: false }
|
|
42
|
+
);
|
|
43
|
+
try {
|
|
44
|
+
const allFeatures = map.queryRenderedFeatures(void 0, {
|
|
45
|
+
layers: interactiveLayerIdsRef.current
|
|
46
|
+
});
|
|
47
|
+
allFeatures.forEach((feature) => {
|
|
48
|
+
if (feature.id !== void 0 && feature.layer.source !== void 0) {
|
|
49
|
+
map.setFeatureState(
|
|
50
|
+
{ source: feature.layer.source, id: feature.id },
|
|
51
|
+
{ isAnyActive: false }
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
34
59
|
const handleClick = (0, import_react.useCallback)(
|
|
35
60
|
({ point }) => {
|
|
36
61
|
let features = [];
|
|
@@ -93,30 +118,20 @@ const useActiveInteraction = (interactiveLayerIds) => {
|
|
|
93
118
|
const onEscapeKeyPressedHandler = (0, import_react.useCallback)(
|
|
94
119
|
(event) => {
|
|
95
120
|
if (event.key === "Escape") {
|
|
96
|
-
|
|
97
|
-
map.setFeatureState(
|
|
98
|
-
{ source: sourceIdRef.current, id: featureIdRef.current },
|
|
99
|
-
{ active: false }
|
|
100
|
-
);
|
|
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
|
-
}
|
|
115
|
-
}
|
|
121
|
+
clearActiveFeatureStates();
|
|
116
122
|
}
|
|
117
123
|
},
|
|
118
124
|
[map]
|
|
119
125
|
);
|
|
126
|
+
(0, import_react.useEffect)(() => {
|
|
127
|
+
const wasJustUnpinned = prevPinnedRef.current && !pinnedFromStore;
|
|
128
|
+
prevPinnedRef.current = pinnedFromStore;
|
|
129
|
+
if (wasJustUnpinned) {
|
|
130
|
+
clearActiveFeatureStates();
|
|
131
|
+
featureIdRef.current = void 0;
|
|
132
|
+
sourceIdRef.current = void 0;
|
|
133
|
+
}
|
|
134
|
+
}, [pinnedFromStore, map]);
|
|
120
135
|
(0, import_react.useEffect)(() => {
|
|
121
136
|
map.on("click", handleClick);
|
|
122
137
|
window.addEventListener("keyup", onEscapeKeyPressedHandler);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { MapShape } from '../types/shapes.js';
|
|
3
|
-
export declare const useAttachSymbolToMap: (icon: string | MapShape | ReactNode, suffix?: string, outputSize?: number) =>
|
|
3
|
+
export declare const useAttachSymbolToMap: (icon: string | MapShape | ReactNode, suffix?: string, outputSize?: number) => void;
|
|
@@ -23,15 +23,15 @@ __export(use_attach_symbol_to_map_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(use_attach_symbol_to_map_exports);
|
|
24
24
|
var import_react_maplibre = require("@vis.gl/react-maplibre");
|
|
25
25
|
var import_lodash_es = require("lodash");
|
|
26
|
+
var import_react = require("react");
|
|
26
27
|
var import_use_attach_image_from_icon = require("./use-attach-image-from-icon.js");
|
|
27
28
|
var import_attach_image_from_string = require("../utils/attach-image-from-string.js");
|
|
28
29
|
const useAttachSymbolToMap = (icon, suffix = "", outputSize) => {
|
|
29
30
|
const { current: map } = (0, import_react_maplibre.useMap)();
|
|
30
31
|
const customIconAttached = (0, import_use_attach_image_from_icon.useAttachImageFromIcon)(icon, suffix, outputSize);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
32
|
+
(0, import_react.useEffect)(() => {
|
|
33
|
+
if (!customIconAttached && (0, import_lodash_es.isString)(icon) && map) {
|
|
34
|
+
(0, import_attach_image_from_string.attachImageFromString)(map, icon, suffix, outputSize);
|
|
35
|
+
}
|
|
36
|
+
}, [customIconAttached, icon, map, outputSize, suffix]);
|
|
37
37
|
};
|
|
@@ -24,6 +24,7 @@ module.exports = __toCommonJS(use_hover_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_use_geo_tooltip_sync = require("./use-geo-tooltip-sync.js");
|
|
27
28
|
var import_associated_features = require("../utils/associated-features.js");
|
|
28
29
|
var import_get_min_value_feature = require("../utils/get-min-value-feature.js");
|
|
29
30
|
const MOUSEMOVE_THROTTLE_MS = 16;
|
|
@@ -81,6 +82,10 @@ const useHoverInteraction = (interactiveLayerIds) => {
|
|
|
81
82
|
const sourceIdRef = (0, import_react.useRef)(void 0);
|
|
82
83
|
const interactiveLayerIdsRef = (0, import_react.useRef)(interactiveLayerIds);
|
|
83
84
|
interactiveLayerIdsRef.current = interactiveLayerIds;
|
|
85
|
+
const inBoundsFromStore = (0, import_use_geo_tooltip_sync.useOverlayTooltipSelector)(
|
|
86
|
+
(state) => state.inBounds
|
|
87
|
+
);
|
|
88
|
+
const prevInBoundsRef = (0, import_react.useRef)(false);
|
|
84
89
|
const handleMouseOut = (0, import_react.useCallback)(() => {
|
|
85
90
|
if (!(0, import_lodash_es.isNil)(map)) {
|
|
86
91
|
blurTrackedFeature(map, featureIdRef, sourceIdRef);
|
|
@@ -121,6 +126,13 @@ const useHoverInteraction = (interactiveLayerIds) => {
|
|
|
121
126
|
),
|
|
122
127
|
[map]
|
|
123
128
|
);
|
|
129
|
+
(0, import_react.useEffect)(() => {
|
|
130
|
+
const wasJustHidden = prevInBoundsRef.current && !inBoundsFromStore;
|
|
131
|
+
prevInBoundsRef.current = inBoundsFromStore;
|
|
132
|
+
if (wasJustHidden && !(0, import_lodash_es.isNil)(map)) {
|
|
133
|
+
blurTrackedFeature(map, featureIdRef, sourceIdRef);
|
|
134
|
+
}
|
|
135
|
+
}, [inBoundsFromStore, map]);
|
|
124
136
|
(0, import_react.useEffect)(() => {
|
|
125
137
|
map?.on("mousemove", throttledMouseMove);
|
|
126
138
|
map?.on("mouseout", handleMouseOut);
|
|
@@ -31,7 +31,8 @@ const MAPLIBRE_RUNTIME_ERROR_PATTERNS = [
|
|
|
31
31
|
"Could not compile vertex shader",
|
|
32
32
|
"Program failed to link",
|
|
33
33
|
"feature index out of bounds",
|
|
34
|
-
"Out of bounds. Index requested"
|
|
34
|
+
"Out of bounds. Index requested",
|
|
35
|
+
"bucket.icon.opacityVertexArray"
|
|
35
36
|
];
|
|
36
37
|
const isMaplibreRuntimeError = (message) => MAPLIBRE_RUNTIME_ERROR_PATTERNS.some((pattern) => message.includes(pattern));
|
|
37
38
|
const useMapRuntimeError = ({
|
|
@@ -46,6 +46,7 @@ const useOverlayEvents = () => {
|
|
|
46
46
|
const dispatch = (0, import_charts._useOverlayTooltipReducer)();
|
|
47
47
|
const store = (0, import_charts._useOverlayTooltipStore)();
|
|
48
48
|
const overlay = (0, import_charts._useOverlayChart)();
|
|
49
|
+
const pinnedFeatureIdRef = (0, import_react.useRef)(void 0);
|
|
49
50
|
const getAbsolutePosition = (event) => {
|
|
50
51
|
return {
|
|
51
52
|
x: Math.round(event.originalEvent.clientX),
|
|
@@ -65,6 +66,23 @@ const useOverlayEvents = () => {
|
|
|
65
66
|
const hideTooltip = () => {
|
|
66
67
|
dispatch({ type: "RESET_TOOLTIP" })();
|
|
67
68
|
setTooltipMarker(void 0, void 0);
|
|
69
|
+
pinnedFeatureIdRef.current = void 0;
|
|
70
|
+
};
|
|
71
|
+
const showHoverTooltip = (event, data, hoveredLayerId) => {
|
|
72
|
+
overlay.clear();
|
|
73
|
+
setTooltipMarker(hoveredLayerId, event.lngLat);
|
|
74
|
+
const pos = getAbsolutePosition(event);
|
|
75
|
+
store.setState(
|
|
76
|
+
(0, import_build_geo_tooltip_state.buildGeoTooltipState)({
|
|
77
|
+
absoluteX: pos.x,
|
|
78
|
+
absoluteY: pos.y,
|
|
79
|
+
relativeX: Math.round(event.point.x),
|
|
80
|
+
relativeY: Math.round(event.point.y),
|
|
81
|
+
pinned: false,
|
|
82
|
+
geometry: layerIdToGeometry(hoveredLayerId),
|
|
83
|
+
metadata: data
|
|
84
|
+
})
|
|
85
|
+
);
|
|
68
86
|
};
|
|
69
87
|
const handleMouseEnter = () => {
|
|
70
88
|
setOverlayState({ mouseInBounds: true });
|
|
@@ -79,20 +97,7 @@ const useOverlayEvents = () => {
|
|
|
79
97
|
event,
|
|
80
98
|
dataLookupRegistry
|
|
81
99
|
);
|
|
82
|
-
|
|
83
|
-
setTooltipMarker(hoveredLayerId, event.lngLat);
|
|
84
|
-
const pos = getAbsolutePosition(event);
|
|
85
|
-
store.setState(
|
|
86
|
-
(0, import_build_geo_tooltip_state.buildGeoTooltipState)({
|
|
87
|
-
absoluteX: pos.x,
|
|
88
|
-
absoluteY: pos.y,
|
|
89
|
-
relativeX: Math.round(event.point.x),
|
|
90
|
-
relativeY: Math.round(event.point.y),
|
|
91
|
-
pinned: false,
|
|
92
|
-
geometry: layerIdToGeometry(hoveredLayerId),
|
|
93
|
-
metadata: data
|
|
94
|
-
})
|
|
95
|
-
);
|
|
100
|
+
showHoverTooltip(event, data ?? [], hoveredLayerId);
|
|
96
101
|
} else {
|
|
97
102
|
const currentState = store.getState();
|
|
98
103
|
if (!currentState.pinned) {
|
|
@@ -120,8 +125,15 @@ const useOverlayEvents = () => {
|
|
|
120
125
|
hideTooltip();
|
|
121
126
|
return;
|
|
122
127
|
}
|
|
128
|
+
const currentState = store.getState();
|
|
129
|
+
if (currentState.pinned && pinnedFeatureIdRef.current === featureId) {
|
|
130
|
+
pinnedFeatureIdRef.current = void 0;
|
|
131
|
+
showHoverTooltip(event, data ?? [], hoveredLayerId);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
123
134
|
overlay.clear();
|
|
124
135
|
setTooltipMarker(hoveredLayerId, event.lngLat);
|
|
136
|
+
pinnedFeatureIdRef.current = featureId;
|
|
125
137
|
const pos = getAbsolutePosition(event);
|
|
126
138
|
store.setState(
|
|
127
139
|
(0, import_build_geo_tooltip_state.buildGeoTooltipState)({
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export type MapViewProviderProps = {
|
|
6
6
|
/** Country code for regions with disputed borders */
|
|
7
|
-
countryCode?: 'CN' | 'IN' | 'IL' | 'MA';
|
|
7
|
+
countryCode?: 'CN' | 'IN' | 'IL' | 'MA' | 'OTHERS';
|
|
8
8
|
/** Whether the world map is displayed */
|
|
9
9
|
displayWorldMap?: boolean;
|
|
10
10
|
};
|
|
@@ -22,4 +22,4 @@ __export(get_scaled_symbol_size_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(get_scaled_symbol_size_exports);
|
|
24
24
|
var import_constants = require("../constants.js");
|
|
25
|
-
const getScaledSymbolSize = (symbolSize = import_constants.DEFAULT_SYMBOL_SIZE) => symbolSize * devicePixelRatio;
|
|
25
|
+
const getScaledSymbolSize = (symbolSize = import_constants.DEFAULT_SYMBOL_SIZE) => Math.max(1, symbolSize * devicePixelRatio);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynatrace/strato-geo",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@turf/midpoint": "^6.5.0",
|
|
43
43
|
"@turf/projection": "^6.5.0",
|
|
44
44
|
"@turf/rhumb-bearing": "^6.5.0",
|
|
45
|
-
"@vanilla-extract/css": "^1.
|
|
45
|
+
"@vanilla-extract/css": "^1.21.1",
|
|
46
46
|
"@vanilla-extract/recipes": "^0.5.7",
|
|
47
47
|
"@vis.gl/react-maplibre": "^8.0.0",
|
|
48
48
|
"d3-array": "^3.2.4",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"@dynatrace-sdk/client-classic-environment-v2": "^5.1.0",
|
|
55
55
|
"@dynatrace-sdk/client-platform-management-service": "^1.7.0",
|
|
56
56
|
"@dynatrace-sdk/units": "^1.5.0",
|
|
57
|
-
"@dynatrace/strato-components": "^3.
|
|
58
|
-
"@dynatrace/strato-design-tokens": "^1.5.
|
|
59
|
-
"@dynatrace/strato-icons": "^2.3.
|
|
57
|
+
"@dynatrace/strato-components": "^3.9.0",
|
|
58
|
+
"@dynatrace/strato-design-tokens": "^1.5.1",
|
|
59
|
+
"@dynatrace/strato-icons": "^2.3.1",
|
|
60
60
|
"react": "^18.0.0",
|
|
61
61
|
"react-dom": "^18.0.0",
|
|
62
62
|
"react-intl": "^6.0.8 || ^7.0.0",
|