2

I have following simple draw interaction:

draw = new ol.interaction.Draw({ features: featureOverlay.getFeatures(), type: (type) }); 

Now I would like to add attributes like a name and id to the feature. Is this possible? I couldn't find an awnser to this anywhere until now.

Does anyone know how to do this?

1 Answer 1

5

You just need to add an event listener on the draw variable

draw.on('drawend', function(e) { e.feature.setProperties({ 'id': 1234, 'name': 'yourCustomName' }) console.log(e.feature, e.feature.getProperties()); }); 

Be aware that there is a a function setId on e.feature but this "id" is a bit different from the one you set in the attributes (see the API docs)

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.