Open drwestco opened 2 years ago
It's also strange that icon-size
didn't affect the height of the blue non-stretchy area.
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.
@zelonewolf, text-in-image-expert, what is your approach with the highway shields?
@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.
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.
maplibre-gl-js version: All
browser: All
Steps to Trigger Behavior
content
,stretchX
andstretchY
options'icon-text-fit': 'both'
and'icon-size': 2
Compare the constant padding around the
content
area at native image size (left) vs the variable padding with'icon-size': 2
(right)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.