The assignment will be quite simple because the component at the time of writing needs some refining. It's possible to edit content but there are no events to catch at the end of modification: we will be unable to save the modified features. We will cover the client as is.
2360_08_01_simple_select.html as 2360_08_08_modify.html.var london, add the following code:var modify = new ol.interaction.Modify({
features: selectInteraction.getFeatures()
});map.getInteractions().extend([selectInteraction]); with the following code:map.getInteractions().extend([selectInteraction, modify]);
var selected_features = selectInteraction.getFeatures();
selected_features.on('add', function(event) {
var feature = event.element;
feature.on('change', function(event){
event.target.getGeometry().getCoordinates());
});
});
We saw in this sample how to use ol.interaction.Modify here using the modify component. We also saw that it requires ol.interaction.Select. To be able to listen to change, there is no available method on ol.interaction.Modify to directly know the modification to the features. You have to listen to changes on features with selected_features.on('add', function(event) {.
To make this behavior really more obvious, we also used a console.log statement, so when using the browser console debugger, you are able to follow the call when a feature is modified.
After reviewing, drawing, and modifying features, it's time to deepen our interactions knowledge: preferring a practical approach, we only scratched the surface (their definitions) until now.