Use ol.coordinate.distance
This commit is contained in:
@@ -327,9 +327,7 @@ ol.interaction.Extent.prototype.snapToVertex_ = function(pixel, map) {
|
|||||||
var vertexPixel = map.getPixelFromCoordinate(vertex);
|
var vertexPixel = map.getPixelFromCoordinate(vertex);
|
||||||
|
|
||||||
//if the distance is within tolerance, snap to the segment
|
//if the distance is within tolerance, snap to the segment
|
||||||
if (Math.sqrt(ol.coordinate.squaredDistance(pixel, vertexPixel)) <=
|
if (ol.coordinate.distance(pixel, vertexPixel) <= this.pixelTolerance_) {
|
||||||
this.pixelTolerance_) {
|
|
||||||
|
|
||||||
//test if we should further snap to a vertex
|
//test if we should further snap to a vertex
|
||||||
var pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
|
var pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
|
||||||
var pixel2 = map.getPixelFromCoordinate(closestSegment[1]);
|
var pixel2 = map.getPixelFromCoordinate(closestSegment[1]);
|
||||||
|
|||||||
@@ -371,8 +371,7 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
|
|||||||
vertex = (ol.coordinate.closestOnSegment(pixelCoordinate,
|
vertex = (ol.coordinate.closestOnSegment(pixelCoordinate,
|
||||||
closestSegment));
|
closestSegment));
|
||||||
vertexPixel = map.getPixelFromCoordinate(vertex);
|
vertexPixel = map.getPixelFromCoordinate(vertex);
|
||||||
if (Math.sqrt(ol.coordinate.squaredDistance(pixel, vertexPixel)) <=
|
if (ol.coordinate.distance(pixel, vertexPixel) <= this.pixelTolerance_) {
|
||||||
this.pixelTolerance_) {
|
|
||||||
snapped = true;
|
snapped = true;
|
||||||
if (this.vertex_) {
|
if (this.vertex_) {
|
||||||
pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
|
pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
|
||||||
|
|||||||
Reference in New Issue
Block a user