Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icons rescaled after print #1476

Closed
jokd opened this issue Feb 23, 2022 · 5 comments · Fixed by #1514
Closed

Icons rescaled after print #1476

jokd opened this issue Feb 23, 2022 · 5 comments · Fixed by #1514
Assignees
Labels

Comments

@jokd
Copy link
Contributor

jokd commented Feb 23, 2022

Describe the bug
When using scaled symbols in the map, the scale seems to be overlooked when re rendering the map after the print preview.
Eg:

		"symbol": [
			[{
				"icon": {
					"size": [64, 64],
					"src": "icon.png",
					"scale": 0.5
				}
			}]
		],

Screenshots
Before print:
image

After:
image

Ideas on this @Grammostola ?

@jokd jokd added the bug label Feb 23, 2022
@jokd
Copy link
Contributor Author

jokd commented Feb 23, 2022

Had a go at it but I am probably destroying something since it was written a bit more complicated from the beginning:
d25c9f5

@Grammostola
Copy link
Contributor

Grammostola commented Feb 23, 2022

Acknowledged. I'm not sure I've seen the scale property of an icon style before, but you are right, things are scaled back to 100% after a print preview exit. My print-test-mega-map hit a snag on the above commit; I'll have a look at it and how it was before on the morrow. The scale property needs to be taken into account if the longer way, or what causes the snag needs to be worked around if the shorter.

@Grammostola
Copy link
Contributor

I have been unable to make your initial suggestion do what I think is intended, my current thought is that the (original) style scale can be fetched from the viewer and then loop through every feature and update as is currently done (but with the original scale number instead of 1). (A stray thought was a kind of memory at SetLayerScale() but it may not be necessary). I hope to be able to spend some more time with this next week.

@Grammostola
Copy link
Contributor

This seems to work for icons using a scale param in their style (this issue)

    if (isVector(layer)) {
      const styleName = layer.get('styleName');
      const styles = viewer.getStyle(styleName);
      if (styleName && styles && styles.length === 1) {
        const newStyle = Style.createStyle({
          style: styleName,
          viewer
        })();
        if (newStyle) {
          source.getFeatures().forEach(feature => {
            feature.setStyle(newStyle);
          });
        }
      }
    }

however it is as much responsible for the related issue as the current setLayerScale function (entering the print preview)
so I have an alternate solution in the works

@Grammostola
Copy link
Contributor

The alternate solution for this issue and resetLayerScale() needed the selection-robbing setStyle() in setLayerScale() in order to not be selection-robbing, it turns out. I haven't been able to getStyle() of a feature prior to setStyle() on said feature, even if the feature logged seems to have a style_ property before setStyle().

There is a "selected" property of selected features however that I might be able to use.

@Grammostola Grammostola added this to Eskilstuna in Origo member roadmap Mar 23, 2022
sweco-sedalh added a commit to sweco-sedalh/origo that referenced this issue Apr 1, 2022
sweco-sedalh added a commit to sweco-sedalh/origo that referenced this issue Apr 6, 2022
sweco-sedalh added a commit to sweco-sedalh/origo that referenced this issue Apr 26, 2022
sweco-sedalh added a commit to sweco-sedalh/origo that referenced this issue May 27, 2022
johnnyblasta added a commit that referenced this issue May 30, 2022
Fix for #1476 and #1482 (correct styling upon exiting print view)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

2 participants