Reputation: 1
In my OpenLayers3 map, I can easily create points or linestrings. When I modify linestrings, I can set up the Modify interaction to be able to delete a vertex on a shift-click. I then get a callback on the linestring feature on('change') event.
For points, I get no such callback and in fact the shift-click does not delete the point.
I was referencing this example: http://openlayers.org/en/v3.2.1/examples/draw-and-modify-features.html?q=modify
Now that I think about it, what I really might want to do is have a select interaction and when the user selects a point with a shift-click, that point would be deleted.
Has anyone else solved this problem?
Thanks
-- I updated my application to have a selection handler for deletion; Now I'm having a problem where the selection is happening on a click, even though I specify it should select on a shift-click.
this.stationDeleter = new ol.interaction.Select({
layers: [this.stationsLayer],
// for debugging
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 12,
fill: new ol.style.Fill({
color: 'rgba(255, 0, 0, 0.5)'
})
})
}),
addCondition: function(event) {
return ol.events.condition.shiftKeyOnly(event)
&& ol.events.condition.singleClick(event);
}
});
Upvotes: 0
Views: 5293
Reputation: 6011
There is a difference between deleting a vertex of a feature and deleting the whole geometry. To delete the whole geometry it's a good idea to use a Select
interaction. Like in this example: http://openlayers.org/en/master/examples/modify-features.html
If there is a feature selected, you could show a control with a button "Remove selected feature".
Upvotes: 0