@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
package/dist/components/index.js
CHANGED
|
@@ -993,9 +993,16 @@ function GeoMap({
|
|
|
993
993
|
const updateDimensions = () => {
|
|
994
994
|
if (containerRef.current) {
|
|
995
995
|
const rect = containerRef.current.getBoundingClientRect();
|
|
996
|
-
setContainerDimensions({
|
|
997
|
-
|
|
998
|
-
|
|
996
|
+
setContainerDimensions((prev) => {
|
|
997
|
+
const newWidth = rect.width || 800;
|
|
998
|
+
const newHeight = rect.height || calculatedHeight;
|
|
999
|
+
if (prev.width === newWidth && prev.height === newHeight) {
|
|
1000
|
+
return prev;
|
|
1001
|
+
}
|
|
1002
|
+
return {
|
|
1003
|
+
width: newWidth,
|
|
1004
|
+
height: newHeight
|
|
1005
|
+
};
|
|
999
1006
|
});
|
|
1000
1007
|
}
|
|
1001
1008
|
};
|
|
@@ -1132,6 +1139,7 @@ function GeoMap({
|
|
|
1132
1139
|
const [dynamicPanelPosition, setDynamicPanelPosition] = React3.useState(
|
|
1133
1140
|
panelPosition
|
|
1134
1141
|
);
|
|
1142
|
+
const viewStateRef = React3.useRef(uncontrolledViewState);
|
|
1135
1143
|
React3.useEffect(() => {
|
|
1136
1144
|
if (!viewState && !defaultViewState) {
|
|
1137
1145
|
setUncontrolledViewState({
|
|
@@ -1143,6 +1151,9 @@ function GeoMap({
|
|
|
1143
1151
|
}, [firstCoordinate, calculatedZoom, viewState, defaultViewState]);
|
|
1144
1152
|
const isControlledViewState = viewState !== void 0;
|
|
1145
1153
|
const resolvedViewState = isControlledViewState ? viewState : uncontrolledViewState;
|
|
1154
|
+
React3.useEffect(() => {
|
|
1155
|
+
viewStateRef.current = resolvedViewState || uncontrolledViewState;
|
|
1156
|
+
}, [resolvedViewState, uncontrolledViewState]);
|
|
1146
1157
|
const applyViewState = React3.useCallback(
|
|
1147
1158
|
(nextState) => {
|
|
1148
1159
|
if (!isControlledViewState) {
|
|
@@ -1211,17 +1222,15 @@ function GeoMap({
|
|
|
1211
1222
|
markerId: marker.id,
|
|
1212
1223
|
clusterId: marker.clusterId
|
|
1213
1224
|
});
|
|
1214
|
-
const
|
|
1215
|
-
|
|
1216
|
-
|
|
1225
|
+
const currentState = viewStateRef.current;
|
|
1226
|
+
const center = {
|
|
1227
|
+
latitude: currentState.latitude ?? 0,
|
|
1228
|
+
longitude: currentState.longitude ?? 0
|
|
1217
1229
|
};
|
|
1218
1230
|
const optimalPosition = getOptimalPanelPosition(
|
|
1219
1231
|
marker.latitude,
|
|
1220
1232
|
marker.longitude,
|
|
1221
|
-
|
|
1222
|
-
latitude: currentCenter.latitude ?? firstCoordinate.latitude,
|
|
1223
|
-
longitude: currentCenter.longitude ?? firstCoordinate.longitude
|
|
1224
|
-
}
|
|
1233
|
+
center
|
|
1225
1234
|
);
|
|
1226
1235
|
setDynamicPanelPosition(optimalPosition);
|
|
1227
1236
|
applyViewState({
|
|
@@ -1231,7 +1240,7 @@ function GeoMap({
|
|
|
1231
1240
|
});
|
|
1232
1241
|
emitSelectionChange({ type: "marker", marker });
|
|
1233
1242
|
},
|
|
1234
|
-
[applyViewState, emitSelectionChange, markerFocusZoom
|
|
1243
|
+
[applyViewState, emitSelectionChange, markerFocusZoom]
|
|
1235
1244
|
);
|
|
1236
1245
|
const selectCluster = React3.useCallback(
|
|
1237
1246
|
(cluster) => {
|
|
@@ -1239,17 +1248,15 @@ function GeoMap({
|
|
|
1239
1248
|
type: "cluster",
|
|
1240
1249
|
clusterId: cluster.id
|
|
1241
1250
|
});
|
|
1242
|
-
const
|
|
1243
|
-
|
|
1244
|
-
|
|
1251
|
+
const currentState = viewStateRef.current;
|
|
1252
|
+
const center = {
|
|
1253
|
+
latitude: currentState.latitude ?? 0,
|
|
1254
|
+
longitude: currentState.longitude ?? 0
|
|
1245
1255
|
};
|
|
1246
1256
|
const optimalPosition = getOptimalPanelPosition(
|
|
1247
1257
|
cluster.latitude,
|
|
1248
1258
|
cluster.longitude,
|
|
1249
|
-
|
|
1250
|
-
latitude: currentCenter.latitude ?? firstCoordinate.latitude,
|
|
1251
|
-
longitude: currentCenter.longitude ?? firstCoordinate.longitude
|
|
1252
|
-
}
|
|
1259
|
+
center
|
|
1253
1260
|
);
|
|
1254
1261
|
setDynamicPanelPosition(optimalPosition);
|
|
1255
1262
|
applyViewState({
|
|
@@ -1259,7 +1266,7 @@ function GeoMap({
|
|
|
1259
1266
|
});
|
|
1260
1267
|
emitSelectionChange({ type: "cluster", cluster });
|
|
1261
1268
|
},
|
|
1262
|
-
[applyViewState, clusterFocusZoom, emitSelectionChange
|
|
1269
|
+
[applyViewState, clusterFocusZoom, emitSelectionChange]
|
|
1263
1270
|
);
|
|
1264
1271
|
const clearSelection = React3.useCallback(() => {
|
|
1265
1272
|
setSelection({ type: "none" });
|