aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-04-12 15:42:04 -0700
committerAnton Tananaev <anton@traccar.org>2024-04-12 15:42:04 -0700
commit96169f072b9b88ecf56048015cdb86a14c2e8915 (patch)
treebfdf71bb9e5f388b41baae47ab00459afc19d708 /src
parenta50f998f7dbb297ca7f22a31119556d6c58494c6 (diff)
downloadtrackermap-web-96169f072b9b88ecf56048015cdb86a14c2e8915.tar.gz
trackermap-web-96169f072b9b88ecf56048015cdb86a14c2e8915.tar.bz2
trackermap-web-96169f072b9b88ecf56048015cdb86a14c2e8915.zip
Fix map cluster zoom
Diffstat (limited to 'src')
-rw-r--r--src/map/MapPositions.js14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/map/MapPositions.js b/src/map/MapPositions.js
index c79a0c58..83160a7a 100644
--- a/src/map/MapPositions.js
+++ b/src/map/MapPositions.js
@@ -6,6 +6,7 @@ import { map } from './core/MapView';
import { formatTime, getStatusColor } from '../common/util/formatter';
import { mapIconKey } from './core/preloadImages';
import { useAttributePreference, usePreference } from '../common/util/preferences';
+import { useCatchCallback } from '../reactHelper';
const MapPositions = ({ positions, onClick, showStatus, selectedPosition, titleField }) => {
const id = useId();
@@ -66,19 +67,16 @@ const MapPositions = ({ positions, onClick, showStatus, selectedPosition, titleF
}
}, [onClick]);
- const onClusterClick = useCallback((event) => {
+ const onClusterClick = useCatchCallback(async (event) => {
event.preventDefault();
const features = map.queryRenderedFeatures(event.point, {
layers: [clusters],
});
const clusterId = features[0].properties.cluster_id;
- map.getSource(id).getClusterExpansionZoom(clusterId, (error, zoom) => {
- if (!error) {
- map.easeTo({
- center: features[0].geometry.coordinates,
- zoom,
- });
- }
+ const zoom = await map.getSource(id).getClusterExpansionZoom(clusterId);
+ map.easeTo({
+ center: features[0].geometry.coordinates,
+ zoom,
});
}, [clusters]);