In OL2 feature id's were generated internally. In OL3 this doesn't seem to be the case since the id's are undefined. I have tried with WKT, JSON, and KML sources and none of them have id's assigned to features. Has the internal feature id been removed from OL3? If not what do I need to do to get the id's generated. I am requesting the id via:
feature.getId();
This is real problem for drag and drop since I don't have control over the files.
Cheers
No, OL3 does not generate any feature IDs.
When reading features, each Format may set the feature ID if it is defined according to the semantics of the format. For GeoJSON, it's the "id" member of the feature (not a property).
When creating new features, it's the responsibility of the application to set the features ID if necessary. Use the setId
method of the feature. If using the Draw interaction, it's drawend
event might be useful.
You should also note these facts about feature IDs in OL3:
No features with duplicate IDs may be in the same source. If you add a feature to a source where a feature with an equal ID exists, the new feature is ignored.
Feature IDs are compared as strings, so 1234
and "1234"
are considered equal.
IDs are included when serializing features according to each Format's specification for feature identifiers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With