1

I have a feature in my OpenLayers vector layer. when I do

feature.getProperties()

I get object like this

{geometry: D, drawnAt: "anygeojson.com", date: "", time: "15:20:16", polu: "vgh"}

I want to remove date property from this so that it will look like this

{geometry: D, drawnAt: "anygeojson.com", time: "15:20:16", polu: "vgh"}

How can I do that?

1

1 Answer 1

1
delete feature.getProperties().date

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete

or

feature.unset('date');

https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html#unset

1
  • Yeah, Unset is an option but the thing is. I'm having a front end where User can add or remove properties via a table, that means when they click on save the table, I want to use all those rows as property for my feature. So It can be an object of whole different properties as well. Dec 8, 2020 at 4:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.