-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add the ability to set icon width/height independently #4675
Comments
You want to stretch the icon vertically? Not possible currently afaik. What's your use case? Some kind of data visualisation? |
Yes. I need to draw arrows on the map, and scale their length as appropriate based on a property. Scaling the whole arrow (both the arrow's width and height) doesn't produce the desired effect, as only the length of the arrow should change. My current workaround is to create arrows out of geojson line string. The only issue is that since these are based on lat/long points, they don't scale as appropriate based on zoom level. I will manually have to enlarge or shrink them depending on zoom, which wasn't an issue if I use icon-image. I am not sure if I can resize the geojson on the fly on each zoom event, as I am dealing with a lot of these geojson arrows. |
I also want this, it allows things like progress bar to complete from 0 to 100 |
We think about this problem most frequently with highway shields, where we want to change the width of the shield icon based on the width of the number inside. The approach we use in our core styles is to create multiple icons with different aspect ratios, and dynamically choose which one to use based on the required width. Just adding an independent height/width control wouldn't work well for two reasons:
One proposal we have for addressing the issue is #4143. Another idea we've been investigating is to support "vector icons", which would allow you to write style expressions to generate basically a mini-SVG on the fly. I'm going to close this issue because I don't think we're likely to do anything that takes the form "set icon width/height independently", but the use case is definitely valid and it's something we want to address. |
mapbox-gl-js version: 0.36.0
Steps to Trigger Behavior
Expected Behavior
Actual Behavior
Is there a way to set icon-height or icon-width? I know we can set icon-size, but this scales images uniformly by both width and height.
The text was updated successfully, but these errors were encountered: