Skip to content

Commit f4c21dd

Browse files
Address issues rendering single image (#191)
1 parent 771aa40 commit f4c21dd

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/viewer.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,9 @@ class VolumeImageViewer {
814814
* intercepting errors
815815
* @param {number[]} [options.mapViewResolutions] Map's view list of
816816
* resolutions.
817-
* @param {boolean} [options.useTileGridResolutions] If true, the tile grid
818-
* resolutions will be used if no map view resolutions are provided.
817+
* @param {boolean} [options.useTileGridResolutions=true] If false,
818+
* zoom will not be limited and the image will fit the viewport extent (no clipping).
819+
* This option will be ignored if there are no thumbnail images available or there's just one image.
819820
*/
820821
constructor (options) {
821822
this[_options] = options
@@ -880,6 +881,10 @@ class VolumeImageViewer {
880881
this[_options].errorInterceptor = error => error
881882
}
882883

884+
if (this[_options].useTileGridResolutions == null) {
885+
this[_options].useTileGridResolutions = true
886+
}
887+
883888
if (this[_options].debug == null) {
884889
this[_options].debug = false
885890
} else {
@@ -1142,10 +1147,19 @@ class VolumeImageViewer {
11421147
tileSizes: this[_pyramid].tileSizes
11431148
})
11441149

1145-
let mapViewResolutions
1150+
let mapViewResolutions =
1151+
this[_options].useTileGridResolutions === false
1152+
? undefined
1153+
: this[_tileGrid].getResolutions()
11461154

1147-
if (has(this[_options], 'useTileGridResolutions')) {
1148-
mapViewResolutions = this[_tileGrid].getResolutions()
1155+
/**
1156+
* If there are no thumbnail images, dont use any resolutions so we can create a thumbnail image by
1157+
* loading the the tiles of the lowest resolution and show the entire extent.
1158+
* Using resolutions will cause the viewer to clip the image to the extent of the viewport. This is
1159+
* not what we want for a thumbnail image.
1160+
*/
1161+
if (!this[_metadata].find((image) => image.ImageType[2] === ImageFlavors.THUMBNAIL) && this[_metadata].length > 1) {
1162+
mapViewResolutions = undefined
11491163
}
11501164

11511165
if (has(this[_options], 'mapViewResolutions')) {
@@ -1451,7 +1465,9 @@ class VolumeImageViewer {
14511465
layers.push(tileDebugLayer)
14521466
}
14531467

1454-
if (Math.max(...this[_pyramid].gridSizes[0]) <= 10) {
1468+
const noThumbnails = !this[_metadata].find((image) => image.ImageType[2] === ImageFlavors.THUMBNAIL) && this[_metadata].length > 1
1469+
1470+
if (Math.max(...this[_pyramid].gridSizes[0]) <= 10 || noThumbnails) {
14551471
const center = getCenter(this[_projection].getExtent())
14561472
this[_overviewMap] = new OverviewMap({
14571473
view: new View({

0 commit comments

Comments
 (0)