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

Using setFeatureState with Vector Tiles #7049

Closed
manassra opened this issue Jul 30, 2018 · 6 comments
Closed

Using setFeatureState with Vector Tiles #7049

manassra opened this issue Jul 30, 2018 · 6 comments

Comments

@manassra
Copy link

mapbox-gl-js version: 0.47.0

Question

Is there a way to use setFeatureState with VectorTile layers if the feature id is a string?

Context: I have a VectorTile source that serves tiles I generated using Tippecanoe. Having noticed that setFeatureState relies on having a unique id for each feature, I tried re-generating the tiles with Tippecanoe, this time with setting the id property for each feature with it's uuid property (an identifier that I don't control myself). Tippecanoe complains that non-numeric ids aren't allowed according to the Vector Tile Spec. How do I set the state of the feature if I can't set its id? Can setFeatureState be used with properties (by having id under the feature properties)?

@asheemmamoowala
Copy link
Contributor

Tippecanoe is reporting correctly that string values are not valid ids in v2.1 of the spec. Try using integer ids instead.
Map#setFeatureState does not work with feature.properties.id, it needs feature.id

@manassra
Copy link
Author

manassra commented Jul 30, 2018

Hi @asheemmamoowala! I unfortunately cannot use integer ids (since the feature ids are generated elsewhere as uuids). Is there any way around this?

@e-n-f
Copy link
Contributor

e-n-f commented Jul 30, 2018

I recently added a Tippecanoe feature to auto-assign numeric IDs, which you may find useful: mapbox/tippecanoe#615

@manassra
Copy link
Author

Thanks for the pointer, @ericfischer. This will be helpful, but I will still have to maintain a mapping between the auto-generated ids and the feature uuids somewhere for the local join to work. I am wondering if there is an easier way to do this.

@devPuppySim
Copy link

Hello, I started using tippecanoe about 15 minutes ago and I have a question on using this new feature.

How exactly would I use this new feature to set the feature.id to be equal to an id attribute in the geojson? In the super basic example command from the documentation, the command I'm using is this (on a Mac): $ tippecanoe -o LHA_tiles.mbtiles -zg --drop-densest-as-needed Desktop/LHA2017_tiles/lha_reallysimple.json.

How do I use --generate-ids to convert my attribute "LHA_NUM" to be the feature.id of the output .mbtiles?

Thanks for your help in advance!

@asheemmamoowala
Copy link
Contributor

@devPuppySim this issue tracker is for reporting bugs and feature requests for the gl-js project only.
For "how do I" questions like this, please refer to the documentation for tippecanoe, and if you can't find the answer there, contact support. Thank you!

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

4 participants