From 5c731176b9984f3d7cfe69b5476bc65b0b8260de Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 7 Feb 2017 08:25:19 +0100 Subject: [PATCH] Use ol.coordinate.distance --- src/ol/interaction/extent.js | 4 +--- src/ol/interaction/snap.js | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ol/interaction/extent.js b/src/ol/interaction/extent.js index d827a2c287..8579fc7a68 100644 --- a/src/ol/interaction/extent.js +++ b/src/ol/interaction/extent.js @@ -327,9 +327,7 @@ ol.interaction.Extent.prototype.snapToVertex_ = function(pixel, map) { var vertexPixel = map.getPixelFromCoordinate(vertex); //if the distance is within tolerance, snap to the segment - if (Math.sqrt(ol.coordinate.squaredDistance(pixel, vertexPixel)) <= - this.pixelTolerance_) { - + if (ol.coordinate.distance(pixel, vertexPixel) <= this.pixelTolerance_) { //test if we should further snap to a vertex var pixel1 = map.getPixelFromCoordinate(closestSegment[0]); var pixel2 = map.getPixelFromCoordinate(closestSegment[1]); diff --git a/src/ol/interaction/snap.js b/src/ol/interaction/snap.js index 6da5ef8315..3e10becec3 100644 --- a/src/ol/interaction/snap.js +++ b/src/ol/interaction/snap.js @@ -371,8 +371,7 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { vertex = (ol.coordinate.closestOnSegment(pixelCoordinate, closestSegment)); vertexPixel = map.getPixelFromCoordinate(vertex); - if (Math.sqrt(ol.coordinate.squaredDistance(pixel, vertexPixel)) <= - this.pixelTolerance_) { + if (ol.coordinate.distance(pixel, vertexPixel) <= this.pixelTolerance_) { snapped = true; if (this.vertex_) { pixel1 = map.getPixelFromCoordinate(closestSegment[0]);