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.
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
OpenLayers. Bounds | Instances of this class represent bounding boxes. |
Constructor | |
OpenLayers. Bounds | Construct a new bounds object. |
Functions | |
toString | {String} String representation of bounds object. |
toArray | {Array} array of left, bottom, right, top |
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. |
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 |
Construct a new bounds object.
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. |
toGeometry: function()
Create a new polygon geometry based on this bounds.
{OpenLayers.Geometry.Polygon} A new polygon with the coordinates of this bounds.
add:function( x, y )
x | {Float} |
y | {Float} |
{OpenLayers.Bounds} A new bounds whose coordinates are the same as this, but shifted by the passed-in x and y values.
containsLonLat:function( ll, inclusive )
ll | {OpenLayers.LonLat} |
inclusive | {Boolean} Whether or not to include the border. Default is true. |
{Boolean} The passed-in lonlat is within this bounds.
containsPixel:function( px, inclusive )
px | {OpenLayers.Pixel} |
inclusive | {Boolean} Whether or not to include the border. Default is true. |
{Boolean} The passed-in pixel is within this bounds.
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.
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. |
{Boolean} The passed-in bounds object intersects this bounds.
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 true, the entire target bounds must be contained within this bounds. |
inclusive | {Boolean} Treat shared edges as contained. Default is true. |
{Boolean} The passed-in bounds object is contained within this bounds.
determineQuadrant: function( lonlat )
lonlat | {OpenLayers.LonLat} |
{String} The quadrant (“br” “tr” “tl” “bl”) of the bounds in which the coordinate lies.
transform: function( source, dest )
Transform the Bounds object from source to dest.
source | {OpenLayers.Projection} Source projection. |
dest | {OpenLayers.Projection} Destination projection. |
{OpenLayers.Bounds} Itself, for use in chaining operations.
wrapDateLine: function( maxExtent, options )
maxExtent | {OpenLayers.Bounds} |
options | {Object} Some possible options are: |
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. |
{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.
OpenLayers.Bounds.fromString = function( str )
Alternative constructor that builds a new OpenLayers.Bounds from a parameter string
str | {String}Comma-separated bounds string. (ex. <i>”5,42,10,45”</i>) |
{OpenLayers.Bounds} New bounds object built from the passed-in String.
OpenLayers.Bounds.fromArray = function( bbox )
Alternative constructor that builds a new OpenLayers.Bounds from an array
bbox | {Array(Float)} Array of bounds values (ex. <i>[5,42,10,45]</i>) |
{OpenLayers.Bounds} New bounds object built from the passed-in Array.
OpenLayers.Bounds.fromSize = function( size )
Alternative constructor that builds a new OpenLayers.Bounds from a size
size | {OpenLayers.Size} |
{OpenLayers.Bounds} New bounds object built from the passed-in size.
{String} String representation of bounds object.
toString:function()
{Array} array of left, bottom, right, top
toArray: function()
toBBOX:function( decimal )
Create a new polygon geometry based on this bounds.
toGeometry: function()
{Float} The width of the bounds
getWidth:function()
{Float} The height of the bounds (top minus bottom).
getHeight:function()
{OpenLayers.Size} The size of the box.
getSize:function()
{OpenLayers.Pixel} The center of the bounds in pixel space.
getCenterPixel:function()
{OpenLayers.LonLat} The center of the bounds in map space.
getCenterLonLat:function()
add:function( x, y )
Extend the bounds to include the point, lonlat, or bounds specified.
extend:function( object )
containsLonLat:function( ll, inclusive )
containsPixel:function( px, inclusive )
contains:function( x, y, inclusive )
Determine whether the target bounds intersects this bounds.
intersectsBounds:function( bounds, inclusive )
Determine whether the target bounds is contained within this bounds.
containsBounds:function( bounds, partial, inclusive )
determineQuadrant: function( lonlat )
Transform the Bounds object from source to dest.
transform: function( source, dest )
wrapDateLine: function( maxExtent, options )
Alternative constructor that builds a new OpenLayers.Bounds from a parameter string
OpenLayers.Bounds.fromString = function( str )
Alternative constructor that builds a new OpenLayers.Bounds from an array
OpenLayers.Bounds.fromArray = function( bbox )
Alternative constructor that builds a new OpenLayers.Bounds from a size
OpenLayers.Bounds.fromSize = function( size )