-
Notifications
You must be signed in to change notification settings - Fork 56
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
identifier field for features #15
Comments
I have modified my local copy to account for this. It sets feature no.1 as id: 0, no.2 as 1 etc.. |
Yes, this could come from input |
Just in case anyone else stumbles on this in need of a solution, here is how to move the 'id' field out of properties and put it in the feature root. It would be nice if GeoJSON.js handled this natively however. // Parse data into GeoJSON.
const geojson = GeoJSON.parse(data, { Point: ['lat', 'lng'] })
// Move 'id' from properties to feature.
geojson.features = geojson.features.map(({ properties: { id, ...otherProperties }, ...rest }) => ({ id, properties: otherProperties, ...rest })) |
Hello again,
In the GeoJSON specification, it's contemplated the possibility of having an identifier field in the GeoJSON objects, stored in the
id
field. It would be great to have GeoJSON.js accept another parameter to specify which field should be parsed into that identifier. As of now, it can be done by iterating the results and moving the id field from properties to the feature.Thanks for your time,
Pedro.
The text was updated successfully, but these errors were encountered: