I am trying to replace the openlayers draw features form by button. I have created three buttons for point, line and polygon features draw. When clicking the first button (value = point) it works fine but clicking second button it doesn't change the drawing value properties (like value = line). Below is my code:
<input id="type" type="button" value="Point">
<input id="type" type="button" value="Linestring">
<input id="type" type="button" value="Polygon">
...
var typeSelect = document.getElementById('type');
document.getElementById('type').onclick = function addInteraction() {
var draw = new ol.interaction.Draw({
source: source,
type: typeSelect.value
});
map.addInteraction(draw);
}
/**
* Handle change event.
*/
typeSelect.onchange = function() {
map.removeInteraction(draw);
addInteraction();
};
addInteraction();