You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
I have modified my local copy to account for this. It sets feature no.1 as id: 0, no.2 as 1 etc..
I could do a pull request for this change - and in my use case it would suffice. However I wanted to ask if anyone has ever had a need for this ID beeing anything other than just a sequencial number.
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.constgeojson=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: