code: function(point, loc) {
          var best = {
              rank: Number.POSITIVE_INFINITY,
              dist: Number.POSITIVE_INFINITY,
              x: null, y: null
          };
          var snapped = false;
          var result, target;
          for(var i=0, len=this.targets.length; i<len; ++i) {
              target = this.targets[i];
              result = this.testTarget(target, loc);
              if(result) {
                  if(this.greedy) {
                      best = result;
                      best.target = target; 
                      snapped = true;
                      break;
                  } else {
                      if((result.rank < best.rank) ||
                         (result.rank === best.rank && result.dist < best.dist)) {
                          best = result;
                          best.target = target;
                          snapped = true;
                      }
                  }
              }
          }
          if(snapped) {
              var proceed = this.events.triggerEvent("beforesnap", {
                  point: point, x: best.x, y: best.y, distance: best.dist,
                  layer: best.target.layer, snapType: this.precedence[best.rank]
              });
              if(proceed !== false) {
                  point.x = best.x;
                  point.y = best.y;
                  this.point = point;
                  this.events.triggerEvent("snap", {
                      point: point,
                      snapType: this.precedence[best.rank],
                      layer: best.target.layer,
                      distance: best.dist
                  });
              } else {
                  snapped = false;
              }
          }
          if(this.point && !snapped) {
              point.x = loc.x;
              point.y = loc.y;
              this.point = null;
              this.events.triggerEvent("unsnap", {point: point});
          }
      }
docs: Method: considerSnapping
  
  Parameters:
  point - {<OpenLayers.Geometry.Point>} The vertex to be snapped (or
  unsnapped).
  loc - {<OpenLayers.Geometry.Point>} The location of the mouse in map
  coords.