mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-14 01:33:03 +00:00
@@ -83,9 +83,19 @@ iD.behavior.Draw = function(context) {
|
||||
function click() {
|
||||
var d = datum();
|
||||
if (d.type === 'way') {
|
||||
var choice = iD.geo.chooseEdge(context.childNodes(d), context.mouse(), context.projection),
|
||||
edge = [d.nodes[choice.index - 1], d.nodes[choice.index]];
|
||||
event.clickWay(choice.loc, edge);
|
||||
var dims = context.map().dimensions(),
|
||||
mouse = context.mouse(),
|
||||
pad = 5,
|
||||
trySnap = mouse[0] > pad && mouse[0] < dims[0] - pad &&
|
||||
mouse[1] > pad && mouse[1] < dims[1] - pad;
|
||||
|
||||
if (trySnap) {
|
||||
var choice = iD.geo.chooseEdge(context.childNodes(d), context.mouse(), context.projection),
|
||||
edge = [d.nodes[choice.index - 1], d.nodes[choice.index]];
|
||||
event.clickWay(choice.loc, edge);
|
||||
} else {
|
||||
event.click(context.map().mouseCoordinates());
|
||||
}
|
||||
|
||||
} else if (d.type === 'node') {
|
||||
event.clickNode(d);
|
||||
|
||||
@@ -30,9 +30,20 @@ iD.behavior.DrawWay = function(context, wayId, index, mode, baseGraph) {
|
||||
|
||||
if (datum.type === 'node' && datum.id !== end.id) {
|
||||
loc = datum.loc;
|
||||
|
||||
} else if (datum.type === 'way' && datum.id !== segment.id) {
|
||||
loc = iD.geo.chooseEdge(context.childNodes(datum), context.mouse(), context.projection).loc;
|
||||
} else {
|
||||
var dims = context.map().dimensions(),
|
||||
mouse = context.mouse(),
|
||||
pad = 5,
|
||||
trySnap = mouse[0] > pad && mouse[0] < dims[0] - pad &&
|
||||
mouse[1] > pad && mouse[1] < dims[1] - pad;
|
||||
|
||||
if (trySnap) {
|
||||
loc = iD.geo.chooseEdge(context.childNodes(datum), context.mouse(), context.projection).loc;
|
||||
}
|
||||
}
|
||||
|
||||
if (!loc) {
|
||||
loc = context.map().mouseCoordinates();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user