Skip to content

Commit

Permalink
draw-tools: fix "snap to portals" precision (#481)
Browse files Browse the repository at this point in the history
* Fix drawtools snap precision

if a drawtool marker is just slightly off (<1e-9) snap won't change the
location. By using a hard comparsion instead of the soft "equal" it will
reset the position to the portal position in every case.
  • Loading branch information
McBen committed May 17, 2021
1 parent ab3b4ab commit a701aae
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugins/draw-tools.js
Expand Up @@ -583,8 +583,8 @@ window.plugin.drawTools.snapToPortals = function() {
if (visibleBounds.contains(ll)) {
testCount++;
var newll = findClosestPortalLatLng(ll);
if (!newll.equals(ll)) {
layer.setLatLng(new L.LatLng(newll.lat,newll.lng));
if (newll.lat !== ll.lat || newll.lng !== ll.lng) { // must be strict
layer.setLatLng(new L.LatLng(newll.lat, newll.lng));
changedCount++;
}
}
Expand All @@ -595,8 +595,8 @@ window.plugin.drawTools.snapToPortals = function() {
if (visibleBounds.contains(lls[i])) {
testCount++;
var newll = findClosestPortalLatLng(lls[i]);
if (!newll.equals(lls[i])) {
lls[i] = new L.LatLng(newll.lat,newll.lng);
if (newll.lat !== lls[i].lat || newll.lng !== lls[i].lng) {
lls[i] = new L.LatLng(newll.lat, newll.lng);
changedCount++;
layerChanged = true;
}
Expand Down

0 comments on commit a701aae

Please sign in to comment.