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

TextStyle properties behave inconsistently #100

Closed
wahlatlas opened this issue Jul 9, 2023 · 3 comments
Closed

TextStyle properties behave inconsistently #100

wahlatlas opened this issue Jul 9, 2023 · 3 comments
Assignees

Comments

@wahlatlas
Copy link

wahlatlas commented Jul 9, 2023

within the TextStyle

the following works

        text: (v) => v >100 ? v : '',  
        fontSize: (v, r, s, zf) => zf >1 ? 0.4*r : 0.6*r,
        color: () => 'lime',

but this doesn't (always results in purple or no text)

        color: (v, r, s, zf) => zf >2 ? 'lime' : 'purple',
        text: (v, r, s, zf) => zf >2 ? v : '',

what am I doing wrong?

the original example has the following for color

        color: (v, r, s) => d3.interpolateSpectral(1 - (v - s.min) / (s.max - s.min))

but it should work without D3-scales, I guess
and, more importantly, it should also work dependent on zoom factor

@jgaffuri jgaffuri self-assigned this Jul 9, 2023
@wahlatlas
Copy link
Author

Do I understand correctly that you can control layer visibility with minZoom/maxZoom but that there is no equivalent for styles, yes?

@jgaffuri
Copy link
Contributor

minZoom and maxZoom are available at both layer and style level !
In such a way, you can controle when a layer OR only a style used by this layer or another layer, should become visible or not depending on the zoom factor.

(in fact, a better way would be to model this as a function isVisible which would have as parameters the zoom factor and also the position. So that the layer/style visibility could also be set depending on the map position... and maybe other parameters).

@jgaffuri
Copy link
Contributor

within the TextStyle

the following works

        text: (v) => v >100 ? v : '',  
        fontSize: (v, r, s, zf) => zf >1 ? 0.4*r : 0.6*r,
        color: () => 'lime',

but this doesn't (always results in purple or no text)

        color: (v, r, s, zf) => zf >2 ? 'lime' : 'purple',
        text: (v, r, s, zf) => zf >2 ? v : '',

what am I doing wrong?

the original example has the following for color

        color: (v, r, s) => d3.interpolateSpectral(1 - (v - s.min) / (s.max - s.min))

but it should work without D3-scales, I guess and, more importantly, it should also work dependent on zoom factor

There was indeed a bug there. The color and text were ignoring the zoom factor by mistake.
It was corrected in the newly published 2.0.39 version !
Thanks again for this ! And sorry for these nasty bugs...

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

No branches or pull requests

2 participants