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

Nested objects with GeoJSON will not after setFeatureState #7194

Open
iokill opened this issue Aug 24, 2018 · 1 comment
Open

Nested objects with GeoJSON will not after setFeatureState #7194

iokill opened this issue Aug 24, 2018 · 1 comment

Comments

@iokill
Copy link

iokill commented Aug 24, 2018

Hi!

mapbox-gl-js version: v0.48

browser: Chrome 68.0.3440.106

Steps to Trigger Behavior

Playing around with the hover-styles example (https://www.mapbox.com/mapbox-gl-js/example/hover-styles/), I encountered an issue that nested objects in a features object will not work after setFeatureState is called.

More specifically, doing this will work fine on initial rendering.

"line-color":
    ["case", ["boolean", ["feature-state", "hover"], false],
        ["get", "default-color"],
        ["get", "0", ["get", "colors"]]
],

However, after a mouseover and mouseleave, it will however revert to using the default fallback line color instead of the one retrieved with ["get", "0", ["get", "colors"]].

Additionally, this warning will be logged to the console:
Expected value to be of type object, but found string instead.

Link to Demonstration

https://jsfiddle.net/43bq7mfg/

Expected Behavior

Using get on nested objects in feature properties to work after using setFeatureState()

Actual Behavior

Using get on nested objects in feature properties logs a warning and will revert to the fallback/default value.

I'm not sure, but could this be related to #2434?

@jfirebaugh
Copy link
Contributor

Great find and thanks for the thorough writeup @iokill. You're correct that this is related to #2434. Although I think we should keep this issue open for tracking purposes, the underlying cause is the same:

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

No branches or pull requests

3 participants