code: function(geometry, options) {
          var edge = !(options && options.edge === false);
          var details = edge && options && options.details;
          var result, best, distance;
          var min = Number.POSITIVE_INFINITY;
          for(var i=0, len=this.components.length; i<len; ++i) {
              result = this.components[i].distanceTo(geometry, options);
              distance = details ? result.distance : result;
              if(distance < min) {
                  min = distance;
                  best = result;
                  if(min == 0) {
                      break;
                  }
              }
          }
          return best;
      }
docs: APIMethod: distanceTo
  Calculate the closest distance between two geometries (on the x-y plane).
  
  Parameters:
  geometry - {<OpenLayers.Geometry>} The target geometry.
  options - {Object} Optional properties for configuring the distance
  calculation.
  
  Valid options:
  details - {Boolean} Return details from the distance calculation.
  Default is false.
  edge - {Boolean} Calculate the distance from this geometry to the
  nearest edge of the target geometry.  Default is true.  If true,
  calling distanceTo from a geometry that is wholly contained within
  the target will result in a non-zero distance.  If false, whenever
  geometries intersect, calling distanceTo will return 0.  If false,
  details cannot be returned.
  
  Returns:
  {Number | Object} The distance between this geometry and the target.
  If details is true, the return will be an object with distance,
  x0, y0, x1, and y1 properties.  The x0 and y0 properties represent
  the coordinates of the closest point on this geometry. The x1 and y1
  properties represent the coordinates of the closest point on the
  target geometry.