@@ -413,11 +413,11 @@ const GeoRasterLayer: (new (options: GeoRasterLayerOptions) => any) & typeof L.C
413413 // pad xmax and ymin of container to tolerate ceil() and floor() in snap()
414414 container : inSimpleCRS
415415 ? [
416- extentOfLayer . xmin ,
417- extentOfLayer . ymin - 0.25 * pixelHeight ,
418- extentOfLayer . xmax + 0.25 * pixelWidth ,
419- extentOfLayer . ymax
420- ]
416+ extentOfLayer . xmin ,
417+ extentOfLayer . ymin - 0.25 * pixelHeight ,
418+ extentOfLayer . xmax + 0.25 * pixelWidth ,
419+ extentOfLayer . ymax
420+ ]
421421 : [ xmin , ymin - 0.25 * pixelHeight , xmax + 0.25 * pixelWidth , ymax ] ,
422422 debug : debugLevel >= 2 ,
423423 origin : inSimpleCRS ? [ extentOfLayer . xmin , extentOfLayer . ymax ] : [ xmin , ymax ] ,
@@ -441,8 +441,28 @@ const GeoRasterLayer: (new (options: GeoRasterLayerOptions) => any) & typeof L.C
441441 const recropTileProj = inSimpleCRS ? recropTileOrig : recropTileOrig . reproj ( code ) ;
442442 const recropTile = recropTileProj . crop ( extentOfTileInMapCRS ) ;
443443 if ( recropTile !== null ) {
444- maxSamplesAcross = Math . ceil ( resolution * ( recropTile . width / extentOfTileInMapCRS . width ) ) ;
445- maxSamplesDown = Math . ceil ( resolution * ( recropTile . height / extentOfTileInMapCRS . height ) ) ;
444+ let resolutionValue ;
445+
446+ if ( typeof resolution === "object" ) {
447+ const zoomLevels = Object . keys ( resolution ) ;
448+ const mapZoom = this . getMap ( ) . getZoom ( ) ;
449+
450+ for ( const key in zoomLevels ) {
451+ if ( Object . prototype . hasOwnProperty . call ( zoomLevels , key ) ) {
452+ const zoomLvl = zoomLevels [ key ] ;
453+ if ( zoomLvl <= mapZoom ) {
454+ resolutionValue = resolution [ zoomLvl ] ;
455+ } else {
456+ break ;
457+ }
458+ }
459+ }
460+ } else {
461+ resolutionValue = resolution ;
462+ }
463+
464+ maxSamplesAcross = Math . ceil ( resolutionValue * ( recropTile . width / extentOfTileInMapCRS . width ) ) ;
465+ maxSamplesDown = Math . ceil ( resolutionValue * ( recropTile . height / extentOfTileInMapCRS . height ) ) ;
446466 }
447467 }
448468
0 commit comments