Skip to content

Commit bc1bb13

Browse files
authored
Merge pull request #903 from SlideRuleEarth/carlos-dev4
Fix zoom layers for maps so that when you go to Analysis it is not black
2 parents 1d157bf + 02f4bb1 commit bc1bb13

File tree

1 file changed

+13
-36
lines changed

1 file changed

+13
-36
lines changed

web-client/src/composables/SrLayers.ts

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ export const layers = ref<{ [key: string]: SrLayer }>({
295295
allowed_reprojections: ['EPSG:3857', 'EPSG:4326'],
296296
init_visibility: true,
297297
init_opacity: 1,
298-
max_zoom: 19
298+
max_zoom: 17
299299
},
300300
'OpenStreetMap Standard': {
301301
title: 'OpenStreetMap Standard',
@@ -403,7 +403,7 @@ export const layers = ref<{ [key: string]: SrLayer }>({
403403
allowed_reprojections: ['EPSG:3857', 'EPSG:4326'],
404404
init_visibility: true,
405405
init_opacity: 1,
406-
max_zoom: 21
406+
max_zoom: 13
407407
},
408408
OpenTopoMap: {
409409
title: 'OpenTopoMap',
@@ -415,7 +415,7 @@ export const layers = ref<{ [key: string]: SrLayer }>({
415415
allowed_reprojections: ['EPSG:3857', 'EPSG:4326'],
416416
init_visibility: true,
417417
init_opacity: 1,
418-
max_zoom: 17
418+
max_zoom: 13
419419
},
420420
'Arctic Ocean Base': {
421421
title: 'Arctic Ocean Base',
@@ -593,7 +593,7 @@ export const layers = ref<{ [key: string]: SrLayer }>({
593593
allowed_reprojections: ['EPSG:3857', 'EPSG:4326'],
594594
init_visibility: true,
595595
init_opacity: 1,
596-
max_zoom: 14
596+
max_zoom: 13
597597
},
598598
// NASA VIIRS True Color imagery - daily satellite imagery
599599
// Date is calculated dynamically (3 days ago) to ensure availability
@@ -737,18 +737,10 @@ export const getLayer = (
737737
visible: srLayer.init_visibility
738738
}
739739

740-
// Set maxZoom on layer if specified in layer definition
741-
// EXCEPT for NASA GIBS and EOX layers - they need source maxZoom for tile limiting but no layer maxZoom for overzooming
742-
const isNasaGibsLayer = srLayer.url.includes('gibs.earthdata.nasa.gov')
743-
const isEoxLayer = srLayer.url.includes('tiles.maps.eox.at')
744-
if (srLayer.max_zoom !== undefined && !isNasaGibsLayer && !isEoxLayer) {
745-
localTileLayerOptions.maxZoom = srLayer.max_zoom
746-
logger.debug('[SrLayers] Setting layer maxZoom:', {
747-
layerTitle: title,
748-
layerMaxZoom: srLayer.max_zoom,
749-
sourceProjection: srLayer.source_projection
750-
})
751-
}
740+
// Note: Layer maxZoom is NOT set here - we use source maxZoom instead to enable overzooming
741+
// This allows tiles to be scaled when zooming beyond the available zoom level
742+
// rather than hiding the layer completely
743+
752744
if (cachedLayer) {
753745
layerInstance = cachedLayer // Return the cached layer if it exists
754746
logger.debug('Using cached layer', { title, projectionName })
@@ -795,33 +787,18 @@ export const getLayer = (
795787
crossOrigin: 'anonymous' // Required for NASA GIBS
796788
}
797789

798-
// NASA GIBS EPSG:3857 layers - set source maxZoom to enable overzooming
799-
// This prevents tile requests beyond availability (which return 400 errors)
800-
// and allows OpenLayers to scale existing tiles when zooming beyond the limit
801-
if (
802-
isNasaGibs &&
803-
srLayer.source_projection === 'EPSG:3857' &&
804-
srLayer.max_zoom !== undefined
805-
) {
790+
// Enable overzooming for all XYZ layers with max_zoom defined
791+
// This prevents tile requests beyond availability and allows OpenLayers
792+
// to scale existing tiles when zooming beyond the limit
793+
if (srLayer.max_zoom !== undefined) {
806794
xyzOptions.maxZoom = srLayer.max_zoom
807-
logger.debug('[SrLayers] NASA GIBS EPSG:3857 configured for overzooming:', {
795+
logger.debug('[SrLayers] XYZ layer configured for overzooming:', {
808796
layerTitle: title,
809797
sourceMaxZoom: srLayer.max_zoom,
810798
note: 'Tiles limited to source maxZoom, will scale beyond'
811799
})
812800
}
813801

814-
// EOX Sentinel-2 Cloudless layers - enable overzooming beyond zoom 13
815-
// Tiles are available up to zoom 13, setting source maxZoom enables scaling beyond that
816-
const isEoxLayer = srLayer.url.includes('tiles.maps.eox.at')
817-
if (isEoxLayer) {
818-
xyzOptions.maxZoom = 13
819-
logger.debug('[SrLayers] EOX layer configured for overzooming:', {
820-
layerTitle: title,
821-
sourceMaxZoom: 13,
822-
note: 'Tiles available up to zoom 13, will scale beyond'
823-
})
824-
}
825802
// Add custom tile grid for EPSG:5936 to ensure proper tile loading
826803
if (srLayer.source_projection === 'EPSG:5936') {
827804
xyzOptions.tileGrid = arcticTileGrid

0 commit comments

Comments
 (0)