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

document that setFeatureState needs numeric ids #10105

Closed
andrewharvey opened this issue Nov 16, 2020 · 5 comments · Fixed by #10356
Closed

document that setFeatureState needs numeric ids #10105

andrewharvey opened this issue Nov 16, 2020 · 5 comments · Fixed by #10356
Assignees

Comments

@andrewharvey
Copy link
Collaborator

#9559 changed the documentation for setFeatureState which previously read

Features are identified by their id attribute, which must be an integer or a string that can be cast to an integer.

That part was removed, however it appears that string id's don't work when using setFeatureState.

I couldn't find an existing ticket, so short of implementing this so that string id's work, we could better document this limitation.

@geirmarius
Copy link

geirmarius commented Nov 16, 2020

Hey, we're using string IDs without issues in setFeatureState in the latest release version. We're targeting the promoteId which points to a string value in our geojson.

Just wanted to let you know.

@andrewharvey
Copy link
Collaborator Author

Strange I put together a minimal example https://jsfiddle.net/andrewharvey4/1oLj6u8t/3/ and it's not working with string ids.

@geirmarius
Copy link

geirmarius commented Nov 17, 2020

Aha, that makes ... sense. Ids in mapbox cannot be numbers, but you can use promoteId to "promote" another property to use in setFeatureState, and that one can be a string: https://jsfiddle.net/g1wL8q7n/

Not very well documented tho, and I spent hours trying to figure out how to. 😅

@douglasg14b
Copy link

douglasg14b commented Jan 24, 2021

Seriously, I just wasted 1/2 a day trying to figure out why setFeatureState wasn't working. Then I found this issue #7986 that states that is accepts strings that can be coerced into numbers. Except that I'm using hexadecimal strings that are numbers just in base 16...

Please fix the document, this was absolutely exhausting.

image

@asheemmamoowala
Copy link
Contributor

Thanks for the feedback here, I have a small improvement in #10356

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

Successfully merging a pull request may close this issue.

4 participants