From 9d6c0a639814d09c7969c045f0a5b1ae8ddf3431 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mi=C5=82osz=20Grocholewski?= <m.grocholewski@atcomp.pl>
Date: Tue, 5 Nov 2024 10:10:22 +0100
Subject: [PATCH] feat(map-view): set max zoom for small maps

---
 .../Map/MapViewer/utils/config/useOlMapView.ts   | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/components/Map/MapViewer/utils/config/useOlMapView.ts b/src/components/Map/MapViewer/utils/config/useOlMapView.ts
index 43e17b5b..3193f5fa 100644
--- a/src/components/Map/MapViewer/utils/config/useOlMapView.ts
+++ b/src/components/Map/MapViewer/utils/config/useOlMapView.ts
@@ -57,11 +57,23 @@ export const useOlMapView = ({ mapInstance }: UseOlMapViewInput): MapConfig['vie
       zoom: mapInitialPosition.z,
       showFullExtent: OPTIONS.showFullExtent,
       zoomFactor: 2 ** (1 / 3),
-      maxZoom: mapSize.maxZoom * 3,
+      maxZoom:
+        mapSize.width < 1.5 * mapSize.tileSize || mapSize.height < 1.5 * mapSize.tileSize
+          ? Math.max(15, mapSize.maxZoom * 3)
+          : mapSize.maxZoom * 3,
       minZoom: mapSize.minZoom,
       extent,
     }),
-    [mapInitialPosition.z, mapSize.maxZoom, center, extent],
+    [
+      center,
+      mapInitialPosition.z,
+      mapSize.width,
+      mapSize.tileSize,
+      mapSize.height,
+      mapSize.maxZoom,
+      mapSize.minZoom,
+      extent,
+    ],
   );
 
   const view = useMemo(() => new View(viewConfig), [viewConfig]);
-- 
GitLab