mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-05 14:38:05 +02:00
e09666bbdc
Disabling interactive draw undo for now. I know how to fix it but it's a bit tricky. So undo will just drop you out to browse mode for the time being. Fixes #477. Fixes #516.
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
iD.modes.DrawArea = function(wayId) {
|
|
var mode = {
|
|
button: 'area',
|
|
id: 'draw-area'
|
|
};
|
|
|
|
var behavior;
|
|
|
|
mode.enter = function() {
|
|
var way = mode.history.graph().entity(wayId),
|
|
index = -1,
|
|
headId = way.nodes[way.nodes.length - 2],
|
|
tailId = way.first(),
|
|
annotation = way.isDegenerate() ? 'started an area' : 'continued an area';
|
|
|
|
function addHeadTail() {
|
|
behavior.finish();
|
|
}
|
|
|
|
function addNode(node) {
|
|
behavior.addNode(node, annotation);
|
|
}
|
|
|
|
function addWay(way, loc, index) {
|
|
behavior.addWay(way, loc, index, annotation);
|
|
}
|
|
|
|
function add(loc) {
|
|
behavior.add(loc, annotation);
|
|
}
|
|
|
|
behavior = iD.behavior.DrawWay(wayId, headId, tailId, index, mode)
|
|
.on('addHead', addHeadTail)
|
|
.on('addTail', addHeadTail)
|
|
.on('addNode', addNode)
|
|
.on('addWay', addWay)
|
|
.on('add', add);
|
|
|
|
mode.map.surface.call(behavior);
|
|
mode.map.tail('Click to add points to your area. Click the first point to finish the area.', true);
|
|
};
|
|
|
|
mode.exit = function() {
|
|
mode.map.surface.call(behavior.off);
|
|
};
|
|
|
|
return mode;
|
|
};
|