@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
|
@@ -1014,9 +1014,16 @@ function GeoMap({
|
|
|
1014
1014
|
const updateDimensions = () => {
|
|
1015
1015
|
if (containerRef.current) {
|
|
1016
1016
|
const rect = containerRef.current.getBoundingClientRect();
|
|
1017
|
-
setContainerDimensions({
|
|
1018
|
-
|
|
1019
|
-
|
|
1017
|
+
setContainerDimensions((prev) => {
|
|
1018
|
+
const newWidth = rect.width || 800;
|
|
1019
|
+
const newHeight = rect.height || calculatedHeight;
|
|
1020
|
+
if (prev.width === newWidth && prev.height === newHeight) {
|
|
1021
|
+
return prev;
|
|
1022
|
+
}
|
|
1023
|
+
return {
|
|
1024
|
+
width: newWidth,
|
|
1025
|
+
height: newHeight
|
|
1026
|
+
};
|
|
1020
1027
|
});
|
|
1021
1028
|
}
|
|
1022
1029
|
};
|
|
@@ -1153,6 +1160,7 @@ function GeoMap({
|
|
|
1153
1160
|
const [dynamicPanelPosition, setDynamicPanelPosition] = React3__namespace.useState(
|
|
1154
1161
|
panelPosition
|
|
1155
1162
|
);
|
|
1163
|
+
const viewStateRef = React3__namespace.useRef(uncontrolledViewState);
|
|
1156
1164
|
React3__namespace.useEffect(() => {
|
|
1157
1165
|
if (!viewState && !defaultViewState) {
|
|
1158
1166
|
setUncontrolledViewState({
|
|
@@ -1164,6 +1172,9 @@ function GeoMap({
|
|
|
1164
1172
|
}, [firstCoordinate, calculatedZoom, viewState, defaultViewState]);
|
|
1165
1173
|
const isControlledViewState = viewState !== void 0;
|
|
1166
1174
|
const resolvedViewState = isControlledViewState ? viewState : uncontrolledViewState;
|
|
1175
|
+
React3__namespace.useEffect(() => {
|
|
1176
|
+
viewStateRef.current = resolvedViewState || uncontrolledViewState;
|
|
1177
|
+
}, [resolvedViewState, uncontrolledViewState]);
|
|
1167
1178
|
const applyViewState = React3__namespace.useCallback(
|
|
1168
1179
|
(nextState) => {
|
|
1169
1180
|
if (!isControlledViewState) {
|
|
@@ -1232,17 +1243,15 @@ function GeoMap({
|
|
|
1232
1243
|
markerId: marker.id,
|
|
1233
1244
|
clusterId: marker.clusterId
|
|
1234
1245
|
});
|
|
1235
|
-
const
|
|
1236
|
-
|
|
1237
|
-
|
|
1246
|
+
const currentState = viewStateRef.current;
|
|
1247
|
+
const center = {
|
|
1248
|
+
latitude: currentState.latitude ?? 0,
|
|
1249
|
+
longitude: currentState.longitude ?? 0
|
|
1238
1250
|
};
|
|
1239
1251
|
const optimalPosition = getOptimalPanelPosition(
|
|
1240
1252
|
marker.latitude,
|
|
1241
1253
|
marker.longitude,
|
|
1242
|
-
|
|
1243
|
-
latitude: currentCenter.latitude ?? firstCoordinate.latitude,
|
|
1244
|
-
longitude: currentCenter.longitude ?? firstCoordinate.longitude
|
|
1245
|
-
}
|
|
1254
|
+
center
|
|
1246
1255
|
);
|
|
1247
1256
|
setDynamicPanelPosition(optimalPosition);
|
|
1248
1257
|
applyViewState({
|
|
@@ -1252,7 +1261,7 @@ function GeoMap({
|
|
|
1252
1261
|
});
|
|
1253
1262
|
emitSelectionChange({ type: "marker", marker });
|
|
1254
1263
|
},
|
|
1255
|
-
[applyViewState, emitSelectionChange, markerFocusZoom
|
|
1264
|
+
[applyViewState, emitSelectionChange, markerFocusZoom]
|
|
1256
1265
|
);
|
|
1257
1266
|
const selectCluster = React3__namespace.useCallback(
|
|
1258
1267
|
(cluster) => {
|
|
@@ -1260,17 +1269,15 @@ function GeoMap({
|
|
|
1260
1269
|
type: "cluster",
|
|
1261
1270
|
clusterId: cluster.id
|
|
1262
1271
|
});
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1265
|
-
|
|
1272
|
+
const currentState = viewStateRef.current;
|
|
1273
|
+
const center = {
|
|
1274
|
+
latitude: currentState.latitude ?? 0,
|
|
1275
|
+
longitude: currentState.longitude ?? 0
|
|
1266
1276
|
};
|
|
1267
1277
|
const optimalPosition = getOptimalPanelPosition(
|
|
1268
1278
|
cluster.latitude,
|
|
1269
1279
|
cluster.longitude,
|
|
1270
|
-
|
|
1271
|
-
latitude: currentCenter.latitude ?? firstCoordinate.latitude,
|
|
1272
|
-
longitude: currentCenter.longitude ?? firstCoordinate.longitude
|
|
1273
|
-
}
|
|
1280
|
+
center
|
|
1274
1281
|
);
|
|
1275
1282
|
setDynamicPanelPosition(optimalPosition);
|
|
1276
1283
|
applyViewState({
|
|
@@ -1280,7 +1287,7 @@ function GeoMap({
|
|
|
1280
1287
|
});
|
|
1281
1288
|
emitSelectionChange({ type: "cluster", cluster });
|
|
1282
1289
|
},
|
|
1283
|
-
[applyViewState, clusterFocusZoom, emitSelectionChange
|
|
1290
|
+
[applyViewState, clusterFocusZoom, emitSelectionChange]
|
|
1284
1291
|
);
|
|
1285
1292
|
const clearSelection = React3__namespace.useCallback(() => {
|
|
1286
1293
|
setSelection({ type: "none" });
|