diff --git a/frontend/src/services/offline/injectOfflineMode.ts b/frontend/src/services/offline/injectOfflineMode.ts index d33d7403a..469b5fc39 100644 --- a/frontend/src/services/offline/injectOfflineMode.ts +++ b/frontend/src/services/offline/injectOfflineMode.ts @@ -1,4 +1,4 @@ -import L, { LatLngBoundsExpression, Layer, Map } from 'leaflet'; +import L, { LatLngBoundsExpression, LatLngExpression, Layer, Map } from 'leaflet'; import CacheManager from 'services/offline/CacheManager'; import { getMapConfig } from 'components/Map/config'; @@ -6,8 +6,8 @@ import { ControlSaveTiles, getStorageInfo, getStoredTilesAsJson, - savetiles as Lsavetiles, tileLayerOffline as LtileLayerOffline, + savetiles, TileLayerOffline, } from 'leaflet.offline'; @@ -16,20 +16,18 @@ type EventStorageSize = TileLayerOffline & { }; const injectOfflineMode = (map: Map, id: number, bounds: LatLngBoundsExpression) => { - const mapConfig = getMapConfig(); - - const { mapOfflineLayer, mapClassicLayers, zoomAvailableOffline } = mapConfig; + const { mapOfflineLayer, mapClassicLayers, zoomAvailableOffline } = getMapConfig(); const tileLayerOffline = LtileLayerOffline(`${mapOfflineLayer.url}?${id}`, { attribution: mapOfflineLayer?.options?.attribution, subdomains: 'abc', - minZoom: Math.min(...(zoomAvailableOffline ?? [])), }); tileLayerOffline.addTo(map); - const controlInstance: ControlSaveTiles = Lsavetiles(tileLayerOffline, { - zoomlevels: mapConfig.zoomAvailableOffline, + const controlInstance: ControlSaveTiles = savetiles(tileLayerOffline, { + zoomlevels: zoomAvailableOffline, + bounds: bounds ? L.latLngBounds(bounds as [LatLngExpression, LatLngExpression]) : null, confirm(_layer: Layer, successCallback: () => void) { successCallback(); },