Skip to content

Commit

Permalink
Properly "reset" the scaling when exiting print view
Browse files Browse the repository at this point in the history
  • Loading branch information
sweco-sedalh committed Apr 1, 2022
1 parent 17be6fb commit b8e0d31
Showing 1 changed file with 3 additions and 31 deletions.
34 changes: 3 additions & 31 deletions src/controls/print/print-resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,40 +412,10 @@ export default function PrintResize(options = {}) {
}
};

// "Resets" layer by changing scale to 1 or removing DPI parameter
// "Resets" layer by removing DPI parameter
const resetLayerScale = function resetLayerScale(layer) {
const source = layer.getSource();

if (isVector(layer)) {
const features = source.getFeatures();
if (features && features.length) {
const feature = features[0];

// Remove styles instead?
const styles = feature.getStyle();
const scale = 1;
if (Array.isArray(styles)) {
styles.forEach(style => {
const image = style.getImage();
if (image) {
image.setScale(scale);
}

const stroke = style.getStroke();
if (stroke) {
const strokeWidth = stroke.getWidth();
stroke.setWidth(strokeWidth * (150 / resolution));
}

const text = style.getText();
if (text) {
text.setScale(scale);
}
});
}
}
}

if (isImage(layer) && isValidSource(source)) {
const params = source.getParams();

Expand Down Expand Up @@ -592,6 +562,8 @@ export default function PrintResize(options = {}) {
isActive = true;
},
resetLayers() {
resolution = 150;
updateLayers();
resetLayers();
resetWfsThemeLayers();
isActive = false;
Expand Down

0 comments on commit b8e0d31

Please sign in to comment.