diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/MapPositions.js | 14 |
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]); |