@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/index.js
CHANGED
|
@@ -1031,9 +1031,16 @@ function GeoMap({
|
|
|
1031
1031
|
const updateDimensions = () => {
|
|
1032
1032
|
if (containerRef.current) {
|
|
1033
1033
|
const rect = containerRef.current.getBoundingClientRect();
|
|
1034
|
-
setContainerDimensions({
|
|
1035
|
-
|
|
1036
|
-
|
|
1034
|
+
setContainerDimensions((prev) => {
|
|
1035
|
+
const newWidth = rect.width || 800;
|
|
1036
|
+
const newHeight = rect.height || calculatedHeight;
|
|
1037
|
+
if (prev.width === newWidth && prev.height === newHeight) {
|
|
1038
|
+
return prev;
|
|
1039
|
+
}
|
|
1040
|
+
return {
|
|
1041
|
+
width: newWidth,
|
|
1042
|
+
height: newHeight
|
|
1043
|
+
};
|
|
1037
1044
|
});
|
|
1038
1045
|
}
|
|
1039
1046
|
};
|
|
@@ -1170,6 +1177,7 @@ function GeoMap({
|
|
|
1170
1177
|
const [dynamicPanelPosition, setDynamicPanelPosition] = React3.useState(
|
|
1171
1178
|
panelPosition
|
|
1172
1179
|
);
|
|
1180
|
+
const viewStateRef = React3.useRef(uncontrolledViewState);
|
|
1173
1181
|
React3.useEffect(() => {
|
|
1174
1182
|
if (!viewState && !defaultViewState) {
|
|
1175
1183
|
setUncontrolledViewState({
|
|
@@ -1181,6 +1189,9 @@ function GeoMap({
|
|
|
1181
1189
|
}, [firstCoordinate, calculatedZoom, viewState, defaultViewState]);
|
|
1182
1190
|
const isControlledViewState = viewState !== void 0;
|
|
1183
1191
|
const resolvedViewState = isControlledViewState ? viewState : uncontrolledViewState;
|
|
1192
|
+
React3.useEffect(() => {
|
|
1193
|
+
viewStateRef.current = resolvedViewState || uncontrolledViewState;
|
|
1194
|
+
}, [resolvedViewState, uncontrolledViewState]);
|
|
1184
1195
|
const applyViewState = React3.useCallback(
|
|
1185
1196
|
(nextState) => {
|
|
1186
1197
|
if (!isControlledViewState) {
|
|
@@ -1249,17 +1260,15 @@ function GeoMap({
|
|
|
1249
1260
|
markerId: marker.id,
|
|
1250
1261
|
clusterId: marker.clusterId
|
|
1251
1262
|
});
|
|
1252
|
-
const
|
|
1253
|
-
|
|
1254
|
-
|
|
1263
|
+
const currentState = viewStateRef.current;
|
|
1264
|
+
const center = {
|
|
1265
|
+
latitude: currentState.latitude ?? 0,
|
|
1266
|
+
longitude: currentState.longitude ?? 0
|
|
1255
1267
|
};
|
|
1256
1268
|
const optimalPosition = getOptimalPanelPosition(
|
|
1257
1269
|
marker.latitude,
|
|
1258
1270
|
marker.longitude,
|
|
1259
|
-
|
|
1260
|
-
latitude: currentCenter.latitude ?? firstCoordinate.latitude,
|
|
1261
|
-
longitude: currentCenter.longitude ?? firstCoordinate.longitude
|
|
1262
|
-
}
|
|
1271
|
+
center
|
|
1263
1272
|
);
|
|
1264
1273
|
setDynamicPanelPosition(optimalPosition);
|
|
1265
1274
|
applyViewState({
|
|
@@ -1269,7 +1278,7 @@ function GeoMap({
|
|
|
1269
1278
|
});
|
|
1270
1279
|
emitSelectionChange({ type: "marker", marker });
|
|
1271
1280
|
},
|
|
1272
|
-
[applyViewState, emitSelectionChange, markerFocusZoom
|
|
1281
|
+
[applyViewState, emitSelectionChange, markerFocusZoom]
|
|
1273
1282
|
);
|
|
1274
1283
|
const selectCluster = React3.useCallback(
|
|
1275
1284
|
(cluster) => {
|
|
@@ -1277,17 +1286,15 @@ function GeoMap({
|
|
|
1277
1286
|
type: "cluster",
|
|
1278
1287
|
clusterId: cluster.id
|
|
1279
1288
|
});
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1282
|
-
|
|
1289
|
+
const currentState = viewStateRef.current;
|
|
1290
|
+
const center = {
|
|
1291
|
+
latitude: currentState.latitude ?? 0,
|
|
1292
|
+
longitude: currentState.longitude ?? 0
|
|
1283
1293
|
};
|
|
1284
1294
|
const optimalPosition = getOptimalPanelPosition(
|
|
1285
1295
|
cluster.latitude,
|
|
1286
1296
|
cluster.longitude,
|
|
1287
|
-
|
|
1288
|
-
latitude: currentCenter.latitude ?? firstCoordinate.latitude,
|
|
1289
|
-
longitude: currentCenter.longitude ?? firstCoordinate.longitude
|
|
1290
|
-
}
|
|
1297
|
+
center
|
|
1291
1298
|
);
|
|
1292
1299
|
setDynamicPanelPosition(optimalPosition);
|
|
1293
1300
|
applyViewState({
|
|
@@ -1297,7 +1304,7 @@ function GeoMap({
|
|
|
1297
1304
|
});
|
|
1298
1305
|
emitSelectionChange({ type: "cluster", cluster });
|
|
1299
1306
|
},
|
|
1300
|
-
[applyViewState, clusterFocusZoom, emitSelectionChange
|
|
1307
|
+
[applyViewState, clusterFocusZoom, emitSelectionChange]
|
|
1301
1308
|
);
|
|
1302
1309
|
const clearSelection = React3.useCallback(() => {
|
|
1303
1310
|
setSelection({ type: "none" });
|