# OpenLayers.Bounds

Instances of this class represent bounding boxes. Data stored as left, bottom, right, top floats. All values are initialized to null, however, you should make sure you set them before using the bounds for anything.

#### Possible use case

>     bounds = new OpenLayers.Bounds();
>     bounds.extend(new OpenLayers.LonLat(4,5));
>     bounds.extend(new OpenLayers.LonLat(5,6));
>     bounds.toBBOX(); // returns 4,5,5,6

Summary

OpenLayers.Bounds | Instances of this class represent bounding boxes.
Properties |
left | {Number} Minimum horizontal coordinate.
bottom | {Number} Minimum vertical coordinate.
right | {Number} Maximum horizontal coordinate.
top | {Number} Maximum vertical coordinate.
centerLonLat | {OpenLayers.LonLat} A cached center location.
Constructor |
OpenLayers.Bounds | Construct a new bounds object.
Functions |
clone | Create a cloned instance of this bounds.
equals | Test a two bounds for equivalence.
toString | {String} String representation of bounds object.
toArray |
toBBOX |
toGeometry | Create a new polygon geometry based on this bounds.
getWidth | {Float} The width of the bounds
getHeight | {Float} The height of the bounds (top minus bottom).
getSize | {OpenLayers.Size} The size of the box.
getCenterPixel | {OpenLayers.Pixel} The center of the bounds in pixel space.
getCenterLonLat | {OpenLayers.LonLat} The center of the bounds in map space.
scale | Scales the bounds around a pixel or lonlat.
add |
extend | Extend the bounds to include the point, lonlat, or bounds specified.
containsLonLat |
containsPixel |
contains |
intersectsBounds | Determine whether the target bounds intersects this bounds.
containsBounds | Determine whether the target bounds is contained within this bounds.
determineQuadrant |
transform | Transform the Bounds object from source to dest.
wrapDateLine |
fromString | Alternative constructor that builds a new OpenLayers.Bounds from a parameter string
fromArray | Alternative constructor that builds a new OpenLayers.Bounds from an array
fromSize | Alternative constructor that builds a new OpenLayers.Bounds from a size
oppositeQuadrant | Get the opposite quadrant for a given quadrant string.

### Properties

### left

{Number} Minimum horizontal coordinate.

### bottom

{Number} Minimum vertical coordinate.

### right

{Number} Maximum horizontal coordinate.

### top

{Number} Maximum vertical coordinate.

### centerLonLat

{OpenLayers.LonLat} A cached center location. This should not be accessed directly. Use getCenterLonLat instead.

### Constructor

### OpenLayers.Bounds

Construct a new bounds object.

#### Parameters

left | {Number} The left bounds of the box. Note that for width calculations, this is assumed to be less than the right value.
bottom | {Number} The bottom bounds of the box. Note that for height calculations, this is assumed to be more than the top value.
right | {Number} The right bounds.
top | {Number} The top bounds.

### Functions

### clone

> clone:function()

Create a cloned instance of this bounds.

#### Returns

{OpenLayers.Bounds} A fresh copy of the bounds

### equals

> equals:function( | bounds | )

Test a two bounds for equivalence.

#### Parameters

bounds | {OpenLayers.Bounds}

#### Returns

{Boolean} The passed-in bounds object has the same left, right, top, bottom components as this. Note that if bounds passed in is null, returns false.

### toString

> toString:function()

#### Returns

{String} String representation of bounds object.

### toArray

> toArray: function( | reverseAxisOrder | )

#### Parameters

reverseAxisOrder | {Boolean} Should we reverse the axis order?

#### Returns

{Array} array of left, bottom, right, top

### toBBOX

> toBBOX:function( | decimal,
> | reverseAxisOrder | )

#### Parameters

decimal | {Integer} How many significant digits in the bbox coords? Default is 6
reverseAxisOrder | {Boolean} Should we reverse the axis order?

#### Returns

{String} Simple String representation of bounds object. (e.g. <i>”5,42,10,45”</i>)

### toGeometry

> toGeometry: function()

Create a new polygon geometry based on this bounds.

#### Returns

{OpenLayers.Geometry.Polygon} A new polygon with the coordinates of this bounds.

### getWidth

> getWidth:function()

#### Returns

{Float} The width of the bounds

### getHeight

> getHeight:function()

#### Returns

{Float} The height of the bounds (top minus bottom).

### getSize

> getSize:function()

#### Returns

{OpenLayers.Size} The size of the box.

### getCenterPixel

> getCenterPixel:function()

#### Returns

{OpenLayers.Pixel} The center of the bounds in pixel space.

### getCenterLonLat

> getCenterLonLat:function()

#### Returns

{OpenLayers.LonLat} The center of the bounds in map space.

### scale

> scale: function( | ratio,
> | origin | )

Scales the bounds around a pixel or lonlat. Note that the new bounds may return non-integer properties, even if a pixel is passed.

#### Parameters

ratio | {Float}
origin | {OpenLayers.Pixel or OpenLayers.LonLat} Default is center.

#### Returns

{OpenLayers.Bounds} A new bounds that is scaled by ratio from origin.

### add

> add:function( | x,
> | y | )

#### Parameters

x | {Float}
y | {Float}

#### Returns

{OpenLayers.Bounds} A new bounds whose coordinates are the same as this, but shifted by the passed-in x and y values.

### extend

> extend:function( | object | )

Extend the bounds to include the point, lonlat, or bounds specified. Note, this function assumes that left < right and bottom < top.

#### Parameters

object | {Object} Can be LonLat, Point, or Bounds

### containsLonLat

> containsLonLat:function( | ll,
> | inclusive | )

#### Parameters

ll | {OpenLayers.LonLat}
inclusive | {Boolean} Whether or not to include the border. Default is true.

#### Returns

{Boolean} The passed-in lonlat is within this bounds.

### containsPixel

> containsPixel:function( | px,
> | inclusive | )

#### Parameters

px | {OpenLayers.Pixel}
inclusive | {Boolean} Whether or not to include the border. Default is true.

#### Returns

{Boolean} The passed-in pixel is within this bounds.

### contains

> contains:function( | x,
> | y,
> | inclusive | )

#### Parameters

x | {Float}
y | {Float}
inclusive | {Boolean} Whether or not to include the border. Default is true.

#### Returns

{Boolean} Whether or not the passed-in coordinates are within this bounds.

### intersectsBounds

> intersectsBounds:function( | bounds,
> | inclusive | )

Determine whether the target bounds intersects this bounds. Bounds are considered intersecting if any of their edges intersect or if one bounds contains the other.

#### Parameters

bounds | {OpenLayers.Bounds} The target bounds.
inclusive | {Boolean} Treat coincident borders as intersecting. Default is true. If false, bounds that do not overlap but only touch at the border will not be considered as intersecting.

#### Returns

{Boolean} The passed-in bounds object intersects this bounds.

### containsBounds

> containsBounds:function( | bounds,
> | partial,
> | inclusive | )

Determine whether the target bounds is contained within this bounds.

bounds | {OpenLayers.Bounds} The target bounds.
partial | {Boolean} If any of the target corners is within this bounds consider the bounds contained. Default is false. If false, the entire target bounds must be contained within this bounds.
inclusive | {Boolean} Treat shared edges as contained. Default is true.

#### Returns

{Boolean} The passed-in bounds object is contained within this bounds.

### determineQuadrant

> determineQuadrant: function( | lonlat | )

#### Parameters

lonlat | {OpenLayers.LonLat}

#### Returns

{String} The quadrant (“br” “tr” “tl” “bl”) of the bounds in which the coordinate lies.

### transform

> transform: function( | source,
> | dest | )

Transform the Bounds object from source to dest.

#### Parameters

source | {OpenLayers.Projection} Source projection.
dest | {OpenLayers.Projection} Destination projection.

#### Returns

{OpenLayers.Bounds} Itself, for use in chaining operations.

### wrapDateLine

> wrapDateLine: function( | maxExtent,
> | options | )

#### Parameters

maxExtent | {OpenLayers.Bounds}
options | {Object} Some possible options are:

#### Allowed Options

leftTolerance | {float} Allow for a margin of error with the ‘left’ value of this bound. Default is 0.
rightTolerance | {float} Allow for a margin of error with the ‘right’ value of this bound. Default is 0.

#### Returns

{OpenLayers.Bounds} A copy of this bounds, but wrapped around the “dateline” (as specified by the borders of maxExtent). Note that this function only returns a different bounds value if this bounds is entirely outside of the maxExtent. If this bounds straddles the dateline (is part in/part out of maxExtent), the returned bounds will be merely a copy of this one.

### fromString

> OpenLayers.Bounds.fromString = function( | str,
> | reverseAxisOrder | )

Alternative constructor that builds a new OpenLayers.Bounds from a parameter string

#### Parameters

str | {String}Comma-separated bounds string. (e.g. <i>”5,42,10,45”</i>)
reverseAxisOrder | {Boolean} Does the string use reverse axis order?

#### Returns

{OpenLayers.Bounds} New bounds object built from the passed-in String.

### fromArray

> OpenLayers.Bounds.fromArray = function( | bbox,
> | reverseAxisOrder | )

Alternative constructor that builds a new OpenLayers.Bounds from an array

#### Parameters

bbox | {Array(Float)} Array of bounds values (e.g. <i>[5,42,10,45]</i>)
reverseAxisOrder | {Boolean} Does the array use reverse axis order?

#### Returns

{OpenLayers.Bounds} New bounds object built from the passed-in Array.

### fromSize

> OpenLayers.Bounds.fromSize = function( | size | )

Alternative constructor that builds a new OpenLayers.Bounds from a size

#### Parameters

size | {OpenLayers.Size}

#### Returns

{OpenLayers.Bounds} New bounds object built from the passed-in size.

### oppositeQuadrant

> OpenLayers.Bounds.oppositeQuadrant = function( | quadrant | )

Get the opposite quadrant for a given quadrant string.

#### Parameters

quadrant | {String} two character quadrant shortstring

#### Returns

{String} The opposing quadrant (“br” “tr” “tl” “bl”). For Example, if you pass in “bl” it returns “tr”, if you pass in “br” it returns “tl”, etc.

This class represents a longitude and latitude pair

> clone:function()

Create a cloned instance of this bounds.

> equals:function( | bounds | )

Test a two bounds for equivalence.

> toString:function()

{String} String representation of bounds object.

> toArray: function( | reverseAxisOrder | )

> toBBOX:function( | decimal,
> | reverseAxisOrder | )

> toGeometry: function()

Create a new polygon geometry based on this bounds.

> getWidth:function()

{Float} The width of the bounds

> getHeight:function()

{Float} The height of the bounds (top minus bottom).

> getSize:function()

{OpenLayers.Size} The size of the box.
Instances of this class represent a width/height pair

> getCenterPixel:function()

{OpenLayers.Pixel} The center of the bounds in pixel space.
This class represents a screen coordinate, in x and y coordinates

> getCenterLonLat:function()

{OpenLayers.LonLat} The center of the bounds in map space.

> scale: function( | ratio,
> | origin | )

Scales the bounds around a pixel or lonlat.

> add:function( | x,
> | y | )

> extend:function( | object | )

Extend the bounds to include the point, lonlat, or bounds specified.

> containsLonLat:function( | ll,
> | inclusive | )

> containsPixel:function( | px,
> | inclusive | )

> contains:function( | x,
> | y,
> | inclusive | )

> intersectsBounds:function( | bounds,
> | inclusive | )

Determine whether the target bounds intersects this bounds.

> containsBounds:function( | bounds,
> | partial,
> | inclusive | )

Determine whether the target bounds is contained within this bounds.

> determineQuadrant: function( | lonlat | )

> transform: function( | source,
> | dest | )

Transform the Bounds object from source to dest.

> wrapDateLine: function( | maxExtent,
> | options | )

> OpenLayers.Bounds.fromString = function( | str,
> | reverseAxisOrder | )

Alternative constructor that builds a new OpenLayers.Bounds from a parameter string

> OpenLayers.Bounds.fromArray = function( | bbox,
> | reverseAxisOrder | )

Alternative constructor that builds a new OpenLayers.Bounds from an array

> OpenLayers.Bounds.fromSize = function( | size | )

Alternative constructor that builds a new OpenLayers.Bounds from a size

> OpenLayers.Bounds.oppositeQuadrant = function( | quadrant | )

Get the opposite quadrant for a given quadrant string.
Construct a new bounds object.
Polygon is a collection of Geometry.LinearRings.
Class for coordinate transforms between coordinate systems.
Close