aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-04 17:26:35 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-04 17:26:35 -0700
commit53fd7f27b8a84b49ef7e4dafbc9e8ac985d7f3af (patch)
tree262eb6caa4d529258d447b6ea0d046a2b6492938 /modern/src/map
parent3d08afc41a96b347eac2ca5c66d23da65dc814af (diff)
downloadtrackermap-web-53fd7f27b8a84b49ef7e4dafbc9e8ac985d7f3af.tar.gz
trackermap-web-53fd7f27b8a84b49ef7e4dafbc9e8ac985d7f3af.tar.bz2
trackermap-web-53fd7f27b8a84b49ef7e4dafbc9e8ac985d7f3af.zip
Option to disable map clustering
Diffstat (limited to 'modern/src/map')
-rw-r--r--modern/src/map/PositionsMap.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/modern/src/map/PositionsMap.js b/modern/src/map/PositionsMap.js
index 033ec760..2a5be791 100644
--- a/modern/src/map/PositionsMap.js
+++ b/modern/src/map/PositionsMap.js
@@ -4,6 +4,7 @@ import { useDispatch, useSelector } from 'react-redux';
import { map } from './Map';
import { getStatusColor } from '../common/formatter';
import { devicesActions } from '../store';
+import usePersistedState from '../common/usePersistedState';
const PositionsMap = ({ positions }) => {
const id = 'positions';
@@ -12,6 +13,8 @@ const PositionsMap = ({ positions }) => {
const dispatch = useDispatch();
const devices = useSelector((state) => state.devices.items);
+ const [mapCluster] = usePersistedState('mapCluster', true);
+
const createFeature = (devices, position) => {
const device = devices[position.deviceId];
return {
@@ -52,7 +55,7 @@ const PositionsMap = ({ positions }) => {
type: 'FeatureCollection',
features: [],
},
- cluster: true,
+ cluster: mapCluster,
clusterMaxZoom: 14,
clusterRadius: 50,
});
@@ -116,7 +119,7 @@ const PositionsMap = ({ positions }) => {
map.removeSource(id);
}
};
- }, [clusters, onMarkerClick, onClusterClick]);
+ }, [mapCluster, clusters, onMarkerClick, onClusterClick]);
useEffect(() => {
map.getSource(id).setData({