Use geometry type enum for configuring draw interaction

This allows us to cast single-part geometries to multi-part types before adding features to the target layer.  This doesn't yet allow for drawing multi-part geometries with multiple parts.  That can be handled separately.
This commit is contained in:
Tim Schaub
2013-11-12 11:30:32 -07:00
parent 8194ba9f0a
commit 5a898884ec
4 changed files with 61 additions and 12 deletions

View File

@@ -97,24 +97,24 @@ var map = new ol.Map({
})
});
var modeSelect = document.getElementById('mode');
var typeSelect = document.getElementById('type');
var draw; // global so we can remove it later
function addInteraction() {
draw = new ol.interaction.Draw({
layer: vector,
mode: /** @type {ol.interaction.DrawMode} */
(modeSelect.options[modeSelect.selectedIndex].value)
type: /** @type {ol.geom.GeometryType} */
(typeSelect.options[typeSelect.selectedIndex].value)
});
map.addInteraction(draw);
}
/**
* Let user change the draw mode.
* Let user change the geometry type.
* @param {Event} e Change event.
*/
modeSelect.onchange = function(e) {
typeSelect.onchange = function(e) {
map.removeInteraction(draw);
addInteraction();
};