Fix the snap example

This commit is contained in:
Tim Schaub
2018-01-11 10:45:55 -07:00
parent c7e2f6b62f
commit edcdeb1036

View File

@@ -45,7 +45,7 @@ var map = new Map({
}) })
}); });
var Modify = { var ExampleModify = {
init: function() { init: function() {
this.select = new _ol_interaction_Select_(); this.select = new _ol_interaction_Select_();
map.addInteraction(this.select); map.addInteraction(this.select);
@@ -69,7 +69,7 @@ var Modify = {
this.modify.setActive(active); this.modify.setActive(active);
} }
}; };
Modify.init(); ExampleModify.init();
var optionsForm = document.getElementById('options-form'); var optionsForm = document.getElementById('options-form');
@@ -126,20 +126,20 @@ optionsForm.onchange = function(e) {
var type = e.target.getAttribute('name'); var type = e.target.getAttribute('name');
var value = e.target.value; var value = e.target.value;
if (type == 'draw-type') { if (type == 'draw-type') {
Draw.getActive() && Draw.setActive(true); ExampleDraw.getActive() && ExampleDraw.setActive(true);
} else if (type == 'interaction') { } else if (type == 'interaction') {
if (value == 'modify') { if (value == 'modify') {
Draw.setActive(false); ExampleDraw.setActive(false);
Modify.setActive(true); ExampleModify.setActive(true);
} else if (value == 'draw') { } else if (value == 'draw') {
Draw.setActive(true); ExampleDraw.setActive(true);
Modify.setActive(false); ExampleModify.setActive(false);
} }
} }
}; };
Draw.setActive(true); ExampleDraw.setActive(true);
Modify.setActive(false); ExampleModify.setActive(false);
// The snap interaction must be added after the Modify and Draw interactions // The snap interaction must be added after the Modify and Draw interactions
// in order for its map browser event handlers to be fired first. Its handlers // in order for its map browser event handlers to be fired first. Its handlers