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

Issues using a 1x1 icon for icon-text-fit #8347

Closed
tristen opened this issue Jun 12, 2019 · 5 comments
Closed

Issues using a 1x1 icon for icon-text-fit #8347

tristen opened this issue Jun 12, 2019 · 5 comments
Labels

Comments

@tristen
Copy link
Member

tristen commented Jun 12, 2019

I'm using a 1x1 icon that looks like this

<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1" height="1" width="1" version="1.1">
 <path d="M1 0 0 0 0 1 1 1Z" fill="#63A076"/>
</svg>

on a layer that looks like this that uses the icon-text-fit property:

{
    "id": "housenum-label",
    "type": "symbol",
    "source": "composite",
    "source-layer": "housenum_label",
    "layout": {
        "text-field": ["to-string", ["get", "house_num"]],
        "icon-text-fit": "both",
        "icon-image": "fill-green"
    },
    "paint": {"text-color": "hsl(0, 100%, 100%)"}
}

I'm noticing a couple behaviours:

  1. The icon is not completely filling up the space on longer labels

Screen Shot 2019-06-12 at 4 36 09 PM

  1. There's quite a noticeable blur when you zoom in/out.

blur


mapbox-gl-js version: v1.0.0
browser: Google Chrome Version 74.0.3729.169 (Official Build) (64-bit)

Expected behvaviour

For 1. I would expect the icon to fill the entire length of the label.
For 2. I would expect the icon to not blur and recalculate its size on moveend.

Link to Demonstration

https://jsfiddle.net/e7gvdzLr/13/embedded/result/?username=tristen

@kkaefer
Copy link
Member

kkaefer commented Sep 16, 2019

This will be fixed by #8741

@kkaefer kkaefer closed this as completed Sep 24, 2019
@tristen
Copy link
Member Author

tristen commented Nov 14, 2019

@kkaefer has this made it into a version? I'm still seeing this issue when applying a 1px icon to labels to create underlines:

underlines

@kkaefer
Copy link
Member

kkaefer commented Nov 14, 2019

Are you referring to the "blur"? If so, this is intended behavior since we're using linear scaling while the map is being zoomed/rotated. This will become the default state once #8738 lands so there's no switchover. 1×1 stretching icons without #8917 will continue to look like this. You can achieve the desired effect once #8917 lands, and then use a 3×1px icon with a stretch zone.

@tristen
Copy link
Member Author

tristen commented Mar 11, 2020

@kkaefer I'm testing out the new stretchable icon feature and I'm seeing similar behaviour using this icon: default.svg.zip

blurring

@kkaefer
Copy link
Member

kkaefer commented Mar 12, 2020

Icons being blurry while zooming is by design: when you're zooming, the position of the icon changes by fractional pixels (unlike when you're panning). so we decided to disable pixel grid snapping because otherwise they would appear to jiggle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants