Skip to content

Commit 409792a

Browse files
Added new property to allow change default resolutions (#103)
* Added new property to allow change default resolutions * Changed HasOwnProperty for hasOwn and fixed lint issues * Replaced Object.hasOwn for _.has from loadash * Removed lint fixes
1 parent a6a1c2f commit 409792a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/viewer.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { ZoomSlider, Zoom } from 'ol/control'
3939
import { getCenter, getHeight, getWidth } from 'ol/extent'
4040
import { defaults as defaultInteractions } from 'ol/interaction'
4141
import dcmjs from 'dcmjs'
42+
import _ from 'lodash'
4243

4344
import {
4445
AnnotationGroup,
@@ -745,6 +746,8 @@ class VolumeImageViewer {
745746
* the application
746747
* @param {number[]} [options.highlightColor=[140, 184, 198]] - Color that
747748
* should be used to highlight things that get selected by the user
749+
* @param {number[]} [options.mapViewResolutions] Map's view list of
750+
* resolutions. If not passed, the tile grid resolution will be used.
748751
*/
749752
constructor (options) {
750753
this[_options] = options
@@ -965,10 +968,16 @@ class VolumeImageViewer {
965968
tileSizes: this[_pyramid].tileSizes
966969
})
967970

971+
let mapViewResolutions = this[_tileGrid].getResolutions()
972+
973+
if (_.has(this[_options], 'mapViewResolutions')) {
974+
mapViewResolutions = this[_options].mapViewResolutions
975+
}
976+
968977
const view = new View({
969978
center: getCenter(this[_pyramid].extent),
970979
projection: this[_projection],
971-
resolutions: this[_tileGrid].getResolutions(),
980+
resolutions: mapViewResolutions,
972981
rotation: this[_rotation],
973982
constrainOnlyCenter: false,
974983
smoothResolutionConstraint: true,

0 commit comments

Comments
 (0)