Преглед изворни кода

Merge branch 'fix-clustering' of SashaGoncharov19/nomadmania-app into dev

Viktoriia пре 1 година
родитељ
комит
02fa0b489a
1 измењених фајлова са 14 додато и 1 уклоњено
  1. 14 1
      src/utils/mapHelpers.ts

+ 14 - 1
src/utils/mapHelpers.ts

@@ -41,7 +41,20 @@ export const clusterMarkers = (markers: ItemSeries[], currentZoom: number, setCl
     turf.point([+marker.pointJSON[1], +marker.pointJSON[0]], { ...marker })
   ));
 
-  const distance = currentZoom < 7 ? 280 : currentZoom < 9 ? 100 : 35;
+  let distance = 0;
+  switch (true) {
+    case (currentZoom < 7):
+      distance = 280;
+      break;
+    case (currentZoom < 9):
+      distance = 100;
+      break;
+    case (currentZoom < 13):
+      distance = 35;
+      break;
+    default:
+      distance = 0;
+  }
   const maxDistance = Math.max(0.1, distance * Math.pow(0.5, currentZoom / 2));
 
   const clustered = turf.clustersDbscan(points, maxDistance, { minPoints: 11 });