diff --git a/src/ol/geom/point.js b/src/ol/geom/point.js index 13a9973d7f..8d8ab4a343 100644 --- a/src/ol/geom/point.js +++ b/src/ol/geom/point.js @@ -20,6 +20,24 @@ ol.geom.Point = function(coordinates, opt_layout) { goog.inherits(ol.geom.Point, ol.geom.Geometry); +/** + * @inheritDoc + */ +ol.geom.Point.prototype.closestPointXY = + function(x, y, closestPoint, minSquaredDistance) { + var flatCoordinates = this.flatCoordinates; + var squaredDistance = ol.geom.flat.squaredDistance( + x, y, flatCoordinates[0], flatCoordinates[1]); + if (squaredDistance < minSquaredDistance) { + closestPoint[0] = flatCoordinates[0]; + closestPoint[1] = flatCoordinates[1]; + return squaredDistance; + } else { + return minSquaredDistance; + } +}; + + /** * @return {ol.geom.RawPoint} Coordinates. */