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

Require feature id in Map#setFeatureState #6974

Merged
merged 1 commit into from
Jul 18, 2018
Merged

Conversation

asheemmamoowala
Copy link
Contributor

Map#setFeatureState should validate the input feature identifier object for the id field, in addition to source and sourceLayer.

@@ -794,6 +794,10 @@ class Style extends Evented {
this.fire(new ErrorEvent(new Error(`The sourceLayer parameter must be provided for vector source types.`)));
return;
}
if (feature.id == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if you pass an undefined value or empty string as the feature id? Is that considered valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

== null works for undefined and null, but not for "". Ive added that additional check. Using === isn't appropriate here because 0 is a valid id value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good explanation

@strech345
Copy link

does setFeatureState only works if the id-propertyname is "id"? whats happend if it is a different name?

@asheemmamoowala
Copy link
Contributor Author

@strech345 the id field required for this API is the top level feature.id field, not one of the fields in its property collection (feature.propertis.id).

@strech345
Copy link

@asheemmamoowala
thanks. and how to create mbtiles with id by using tippicanoe? Do i only need a geojson which does have the id property?

@asheemmamoowala
Copy link
Contributor Author

@e-n-f
Copy link
Contributor

e-n-f commented Jul 26, 2018

mapbox/tippecanoe#615 adds the most basic --generate-ids option (using the input feature sequence for the ID), with the disclaimer that the IDs are not stable and that their format may change in the future.

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

Successfully merging this pull request may close these issues.

4 participants