diff --git a/src/app/servers/Map.tsx b/src/app/servers/Map.tsx
index f03e736..a1a629a 100644
--- a/src/app/servers/Map.tsx
+++ b/src/app/servers/Map.tsx
@@ -4,27 +4,97 @@ import Server from '@/types/server';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { MapPin } from 'lucide-react';
import ServerComponent from '../dashboard/server';
+import { useEffect, useMemo, useRef, useState } from 'react';
export default function ServerMap({ servers }: { servers: Server[] }) {
- return (
-
+ };
+ handleResize();
+ window.addEventListener('resize', handleResize);
+ return () => window.removeEventListener('resize', handleResize);
+ }, []);
+
+ // 3. Estimate zoom level
+ const zoom = useMemo(() => {
+ if (!bounds) return 2;
+
+ const TILE_SIZE = 256;
+ const WORLD_DIM = { width: viewport.width, height: viewport.height };
+ const ZOOM_MAX = 20;
+
+ const lngDelta = bounds.maxLon - bounds.minLon;
+ const latDelta = bounds.maxLat - bounds.minLat;
+
+ const latZoom = Math.log2(WORLD_DIM.height * 360 / (TILE_SIZE * latDelta));
+ const lngZoom = Math.log2(WORLD_DIM.width * 360 / (TILE_SIZE * lngDelta));
+
+ return Math.max(1, Math.min(Math.min(latZoom, lngZoom) - 2, ZOOM_MAX));
+ }, [bounds, viewport]);
+
+ return (
+
+
+
);
}
\ No newline at end of file