New answers tagged


Problem with your approach is that all the input buttons have the same id, and when you are referencing element by document.getElementById('type'), you get HTML element only for the first one. @Ashok Vanam ESRIAu answer is in the right direction, but to bring context of button to function, it has to be passed as parameter. Also removing of possible previous ...


The code is not properly tied up with HTML controls. Please check the code: < id="typePoint" type="button" value="Point" onclick ="addInteraction()" > < input id="typeLine" type="button" value="Linestring" onclick ="addInteraction()" > < input id="typePolygon" type="button" value="Polygon" onclick ="addInteraction()" > ... ...


Function declaration and assignment is on same line. split them up like this function addInteraction() { var draw = new ol.interaction.Draw({ source: source, type: typeSelect.value }); map.addInteraction(draw); } document.getElementById('type').onclick = addInteraction()

Top 50 recent answers are included