Skip to content

Commit

Permalink
Fix #652 by supplying the correct coord / lat-lng to the actionAddMid…
Browse files Browse the repository at this point in the history
…point call.
  • Loading branch information
Bonkles committed Nov 16, 2022
1 parent 6f952ae commit 0b6551d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/behaviors/BehaviorSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,15 @@ export class BehaviorSelect extends AbstractBehavior {
const data = target.data;
const isMidPoint = data.type === 'midpoint';
const isWay = data instanceof osmWay;
const projection = context.projection;

if (isWay) {
const choice = geoChooseEdge(graph.childNodes(data), context.projection.invert(coord), context.projection);
const loc = projection.invert(coord);
const choice = geoChooseEdge(graph.childNodes(data), coord, projection);
var prev = data.nodes[choice.index - 1];
var next = data.nodes[choice.index];
context.perform(
actionAddMidpoint({ loc: choice.loc, edge: [prev, next] }, osmNode()),
actionAddMidpoint({ loc: loc, edge: [prev, next] }, osmNode()),
t('operations.add.annotation.vertex')
);
context.validator().validate();
Expand Down

0 comments on commit 0b6551d

Please sign in to comment.