@page-speed/maps 0.2.1 → 0.2.2
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/dist/components/geo-map.cjs +26 -19
- package/dist/components/geo-map.cjs.map +1 -1
- package/dist/components/geo-map.js +26 -19
- package/dist/components/geo-map.js.map +1 -1
- package/dist/components/index.cjs +26 -19
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +26 -19
- package/dist/components/index.js.map +1 -1
- package/dist/index.cjs +26 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -895,9 +895,16 @@ function GeoMap({
|
|
|
895
895
|
const updateDimensions = () => {
|
|
896
896
|
if (containerRef.current) {
|
|
897
897
|
const rect = containerRef.current.getBoundingClientRect();
|
|
898
|
-
setContainerDimensions({
|
|
899
|
-
|
|
900
|
-
|
|
898
|
+
setContainerDimensions((prev) => {
|
|
899
|
+
const newWidth = rect.width || 800;
|
|
900
|
+
const newHeight = rect.height || calculatedHeight;
|
|
901
|
+
if (prev.width === newWidth && prev.height === newHeight) {
|
|
902
|
+
return prev;
|
|
903
|
+
}
|
|
904
|
+
return {
|
|
905
|
+
width: newWidth,
|
|
906
|
+
height: newHeight
|
|
907
|
+
};
|
|
901
908
|
});
|
|
902
909
|
}
|
|
903
910
|
};
|
|
@@ -1034,6 +1041,7 @@ function GeoMap({
|
|
|
1034
1041
|
const [dynamicPanelPosition, setDynamicPanelPosition] = React3__namespace.useState(
|
|
1035
1042
|
panelPosition
|
|
1036
1043
|
);
|
|
1044
|
+
const viewStateRef = React3__namespace.useRef(uncontrolledViewState);
|
|
1037
1045
|
React3__namespace.useEffect(() => {
|
|
1038
1046
|
if (!viewState && !defaultViewState) {
|
|
1039
1047
|
setUncontrolledViewState({
|
|
@@ -1045,6 +1053,9 @@ function GeoMap({
|
|
|
1045
1053
|
}, [firstCoordinate, calculatedZoom, viewState, defaultViewState]);
|
|
1046
1054
|
const isControlledViewState = viewState !== void 0;
|
|
1047
1055
|
const resolvedViewState = isControlledViewState ? viewState : uncontrolledViewState;
|
|
1056
|
+
React3__namespace.useEffect(() => {
|
|
1057
|
+
viewStateRef.current = resolvedViewState || uncontrolledViewState;
|
|
1058
|
+
}, [resolvedViewState, uncontrolledViewState]);
|
|
1048
1059
|
const applyViewState = React3__namespace.useCallback(
|
|
1049
1060
|
(nextState) => {
|
|
1050
1061
|
if (!isControlledViewState) {
|
|
@@ -1113,17 +1124,15 @@ function GeoMap({
|
|
|
1113
1124
|
markerId: marker.id,
|
|
1114
1125
|
clusterId: marker.clusterId
|
|
1115
1126
|
});
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1118
|
-
|
|
1127
|
+
const currentState = viewStateRef.current;
|
|
1128
|
+
const center = {
|
|
1129
|
+
latitude: currentState.latitude ?? 0,
|
|
1130
|
+
longitude: currentState.longitude ?? 0
|
|
1119
1131
|
};
|
|
1120
1132
|
const optimalPosition = getOptimalPanelPosition(
|
|
1121
1133
|
marker.latitude,
|
|
1122
1134
|
marker.longitude,
|
|
1123
|
-
|
|
1124
|
-
latitude: currentCenter.latitude ?? firstCoordinate.latitude,
|
|
1125
|
-
longitude: currentCenter.longitude ?? firstCoordinate.longitude
|
|
1126
|
-
}
|
|
1135
|
+
center
|
|
1127
1136
|
);
|
|
1128
1137
|
setDynamicPanelPosition(optimalPosition);
|
|
1129
1138
|
applyViewState({
|
|
@@ -1133,7 +1142,7 @@ function GeoMap({
|
|
|
1133
1142
|
});
|
|
1134
1143
|
emitSelectionChange({ type: "marker", marker });
|
|
1135
1144
|
},
|
|
1136
|
-
[applyViewState, emitSelectionChange, markerFocusZoom
|
|
1145
|
+
[applyViewState, emitSelectionChange, markerFocusZoom]
|
|
1137
1146
|
);
|
|
1138
1147
|
const selectCluster = React3__namespace.useCallback(
|
|
1139
1148
|
(cluster) => {
|
|
@@ -1141,17 +1150,15 @@ function GeoMap({
|
|
|
1141
1150
|
type: "cluster",
|
|
1142
1151
|
clusterId: cluster.id
|
|
1143
1152
|
});
|
|
1144
|
-
const
|
|
1145
|
-
|
|
1146
|
-
|
|
1153
|
+
const currentState = viewStateRef.current;
|
|
1154
|
+
const center = {
|
|
1155
|
+
latitude: currentState.latitude ?? 0,
|
|
1156
|
+
longitude: currentState.longitude ?? 0
|
|
1147
1157
|
};
|
|
1148
1158
|
const optimalPosition = getOptimalPanelPosition(
|
|
1149
1159
|
cluster.latitude,
|
|
1150
1160
|
cluster.longitude,
|
|
1151
|
-
|
|
1152
|
-
latitude: currentCenter.latitude ?? firstCoordinate.latitude,
|
|
1153
|
-
longitude: currentCenter.longitude ?? firstCoordinate.longitude
|
|
1154
|
-
}
|
|
1161
|
+
center
|
|
1155
1162
|
);
|
|
1156
1163
|
setDynamicPanelPosition(optimalPosition);
|
|
1157
1164
|
applyViewState({
|
|
@@ -1161,7 +1168,7 @@ function GeoMap({
|
|
|
1161
1168
|
});
|
|
1162
1169
|
emitSelectionChange({ type: "cluster", cluster });
|
|
1163
1170
|
},
|
|
1164
|
-
[applyViewState, clusterFocusZoom, emitSelectionChange
|
|
1171
|
+
[applyViewState, clusterFocusZoom, emitSelectionChange]
|
|
1165
1172
|
);
|
|
1166
1173
|
const clearSelection = React3__namespace.useCallback(() => {
|
|
1167
1174
|
setSelection({ type: "none" });
|