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

Query line-color of clicked feature #8607

Closed
bloigge opened this issue Aug 8, 2019 · 2 comments
Closed

Query line-color of clicked feature #8607

bloigge opened this issue Aug 8, 2019 · 2 comments

Comments

@bloigge
Copy link

bloigge commented Aug 8, 2019

Is it possible to get the current line-color value (or any other property) of a feature which was queried using queryRenderedFeatures? I think of a method which evaluates the data-driven styling of the layer against the current feature?

Thats the data-driven styling for the line-color property:
{"line-color":{"stops":[["NONE","#1f91ef"],["360","#00d150"]],"property":"projection","type":"categorical"}}

@bloigge bloigge changed the title Display line-color of clicked feature Query line-color of clicked feature Aug 8, 2019
@peterqliu
Copy link
Contributor

peterqliu commented Aug 8, 2019

A combination of queryRenderedFeatures and getPaintProperty on the feature's layer will return the layer's line-color. But if that value is a data-driven style or an expression, there is no way to evaluate either within mbxgl.

But if it's a categorical data-driven rule like you have above, it's easy to implement your own conditional logic, by accessing the relevant property in the queried feature (in your example it would be projection) and translating it to the output color.

@asheemmamoowala
Copy link
Contributor

This would be solved by #8373

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

3 participants