diff --git a/apps/viewer/init.js b/apps/viewer/init.js index 4eec2604d..0cbbe700f 100644 --- a/apps/viewer/init.js +++ b/apps/viewer/init.js @@ -260,18 +260,18 @@ function initCore() { // add center position and zoom - if (data.states != undefined) { - // Rounds a number to the specified number of decimal places. - function roundTo(num, decimalPlaces) { - const factor = 10 ** decimalPlaces; - return Math.round(num * factor) / factor; - } + if (data.geometries.features[data.selected].viewerStates != null || + data.geometries.features[data.selected].viewerStates != undefined) { const decimalPlaces = 3; - attributes.X = data.states.x, - attributes.Y = data.states.y, - attributes.zoom = roundTo(data.states.zoom, decimalPlaces); + attributes.X = data.geometries.features[data.selected].viewerStates.x, + attributes.Y = data.geometries.features[data.selected].viewerStates.y, + attributes.zoom = roundTo(data.geometries.features[data.selected].viewerStates.z, decimalPlaces); + } + // Rounds a number to the specified number of decimal places. + function roundTo(num, decimalPlaces) { + const factor = 10 ** decimalPlaces; + return Math.round(num * factor) / factor; } - body = convertHumanAnnotationToPopupBody(attributes); if ( diff --git a/common/util.js b/common/util.js index fd50cadab..069d91f00 100644 --- a/common/util.js +++ b/common/util.js @@ -472,6 +472,11 @@ function covertToViewportFeature(width, height, og) { og.geometry.type; feature = { type: 'Feature', + viewerStates: { + x: og.viewerStates.x, + y: og.viewerStates.y, + z: og.viewerStates.z, + }, properties: { style: {}, area: null, diff --git a/core/extension/openseadragon-canvas-draw-overlay.js b/core/extension/openseadragon-canvas-draw-overlay.js index 1bb203e82..3f1f780a3 100644 --- a/core/extension/openseadragon-canvas-draw-overlay.js +++ b/core/extension/openseadragon-canvas-draw-overlay.js @@ -1023,6 +1023,11 @@ if (this.drawMode == 'point') { this._current_path_ = { type: 'Feature', + viewerStates: { + x: StatesHelper.getCurrentStates(true).x, + y: StatesHelper.getCurrentStates(true).y, + z: StatesHelper.getCurrentStates(true).z + }, properties: { style: {}, }, @@ -1043,6 +1048,11 @@ properties: { style: {}, }, + viewerStates: { + x: StatesHelper.getCurrentStates(true).x, + y: StatesHelper.getCurrentStates(true).y, + z: StatesHelper.getCurrentStates(true).z, + }, geometry: { type: this.drawMode === 'line' || this.drawMode === 'grid' ?