[OpenLayers-Users] Finding the closest feature

Jesse Bushkar apt94jesse at gmail.com
Thu Oct 8 10:56:55 EDT 2009


I have a question about finding the nearest feature from any given point.  I
have a map with several featues, and I have a point somewhere on that map
that represents my location.  Is there a function I can call that will look
at the existing features in the layer and output the marker?  I'm
envisioning something like this:

var nearPoint = findClosest(myLoc);
var dist = myLoc.distanceTo(nearPoint);
alert(dist);

I guess the way to perform that fake findClosest function is what I'm
looking for.  I'd rather not have to measure individual features, because
these features are being dynamically added, removed, and modified on a map
at any given time.  SO, to simply shuffle through all features at the time
of the function call would be GREAT!

Thanks in advance for any help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091008/d33d6808/attachment.html


More information about the Users mailing list