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

icon-size incompatible with icon-text-fit #989

Open
drwestco opened this issue Feb 11, 2022 · 5 comments
Open

icon-size incompatible with icon-text-fit #989

drwestco opened this issue Feb 11, 2022 · 5 comments
Labels
bug Something isn't working enhancement New feature or request PR is more than welcomed Extra attention is needed

Comments

@drwestco
Copy link
Contributor

maplibre-gl-js version: All

browser: All

Steps to Trigger Behavior

  1. Load an image with content, stretchX and stretchY options
  2. Add a symbol layer that uses this image, with 'icon-text-fit': 'both' and 'icon-size': 2
  3. See how the padding around the text varies with text length.

Compare the constant padding around the content area at native image size (left) vs the variable padding with 'icon-size': 2 (right)

image

Link to Demonstration

https://jsbin.com/ficawow/edit?html,js,output

Expected Behavior

Padding around text within the content area should not change based on text length, just because the image is scaled. It should remain constant, as it is with 1:1 scaling.

@drwestco
Copy link
Contributor Author

It's also strange that icon-size didn't affect the height of the blue non-stretchy area.

@drwestco
Copy link
Contributor Author

Maybe this is by design. It looks like it does the text-based scaling first, then applies icon-size to the result. That feels backwards. When icon-text-fit is being used, the intent is to fit the text into the icon. I'd expect icon-size to go first, applied to the source image (adjusting content, scaleX and scaleY properties by the same scaling factor). Then the text fitting operation applies to the result. This way, you can use icon-size to affect the non-stretchy portions of the image; icon-text-fit to do the rest.

@wipfli
Copy link
Contributor

wipfli commented Feb 11, 2022

@ZeLonewolf, text-in-image-expert, what is your approach with the highway shields?

@ZeLonewolf
Copy link
Contributor

@ZeLonewolf, text-in-image-expert, what is your approach with the highway shields?

😬 the thanks I get for copy/pasting @1ec5's brilliant hack.

In the case of openstreetmap-americana, we are inserting images into formatted expressions, so the images in that case are treated for the most part as text characters, with some exceptions. Thus, in order to make space between adjacent images, we are using the text-letter-spacing property to set the space between them. We are not using any of the icon-* properties because those properties don't apply to text.

@github-actions
Copy link
Contributor

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the stale label Aug 11, 2022
@HarelM HarelM added bug Something isn't working enhancement New feature or request PR is more than welcomed Extra attention is needed and removed stale labels Aug 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request PR is more than welcomed Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants