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 ALKMaps.Bounds(); bounds.extend(new ALKMaps.LonLat(4,5)); bounds.extend(new ALKMaps.LonLat(5,6)); bounds.toBBOX(); // returns 4,5,5,6
ALKMaps. | 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 | {ALKMaps.LonLat} A cached center location. |
Constructor | |
ALKMaps. | 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 | {ALKMaps.Size} The size of the box. |
getCenterPixel | {ALKMaps.Pixel} The center of the bounds in pixel space. |
getCenterLonLat | {ALKMaps.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. |
fromString | Alternative constructor that builds a new ALKMaps.Bounds from a parameter string |
fromArray | Alternative constructor that builds a new ALKMaps.Bounds from an array |
fromSize | Alternative constructor that builds a new ALKMaps.Bounds from a size |
oppositeQuadrant | Get the opposite quadrant for a given quadrant string. |
{ALKMaps.LonLat} A cached center location. This should not be accessed directly. Use getCenterLonLat instead.
Construct a new bounds object. Coordinates can either be passed as four arguments, or as a single argument.
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. |
bounds | {Array(Number)} [left, bottom, right, top] |
clone:function()
Create a cloned instance of this bounds.
{ALKMaps.Bounds} A fresh copy of the bounds
equals:function( bounds )
Test a two bounds for equivalence.
bounds | {ALKMaps.Bounds} |
{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.
toGeometry: function()
Create a new polygon geometry based on this bounds.
{ALKMaps.Geometry.Polygon} A new polygon with the coordinates of this bounds.
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.
ratio | {Float} |
origin | {ALKMaps.Pixel or ALKMaps.LonLat} Default is center. |
{ALKMaps.Bounds} A new bounds that is scaled by ratio from origin.
add:function( x, y )
x | {Float} |
y | {Float} |
{ALKMaps.Bounds} A new bounds whose coordinates are the same as this, but shifted by the passed-in x and y values.
containsLonLat: function( ll, options )
ll | {<ALKMaps.LonLat>|Object} ALKMaps.LonLat or an object with a ‘lon’ and ‘lat’ properties. |
options | {Object} Optional parameters |
inclusive | {Boolean} Whether or not to include the border. Default is true. |
worldBounds | {ALKMaps.Bounds} If a worldBounds is provided, the ll will be considered as contained if it exceeds the world bounds, but can be wrapped around the dateline so it is contained by this bounds. |
{Boolean} The passed-in lonlat is within this bounds.
containsPixel:function( px, inclusive )
px | {ALKMaps.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, options )
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 | {ALKMaps.Bounds} The target bounds. |
options | {Object} Optional parameters. |
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. |
worldBounds | {ALKMaps.Bounds} If a worldBounds is provided, two bounds will be considered as intersecting if they intersect when shifted to within the world bounds. This applies only to bounds that cross or are completely outside the world bounds. |
{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 | {ALKMaps.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. |
{Boolean} The passed-in bounds object is contained within this bounds.
determineQuadrant: function( lonlat )
lonlat | {ALKMaps.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 | {ALKMaps.Projection} Source projection. |
dest | {ALKMaps.Projection} Destination projection. |
{ALKMaps.Bounds} Itself, for use in chaining operations.
ALKMaps.Bounds.fromString = function( str, reverseAxisOrder )
Alternative constructor that builds a new ALKMaps.Bounds from a parameter string
str | {String}Comma-separated bounds string. (e.g. <i>”5,42,10,45”</i>) |
reverseAxisOrder | {Boolean} Does the string use reverse axis order? |
{ALKMaps.Bounds} New bounds object built from the passed-in String.
ALKMaps.Bounds.fromArray = function( bbox, reverseAxisOrder )
Alternative constructor that builds a new ALKMaps.Bounds from an array
bbox | {Array(Float)} Array of bounds values (e.g. <i>[5,42,10,45]</i>) |
reverseAxisOrder | {Boolean} Does the array use reverse axis order? |
{ALKMaps.Bounds} New bounds object built from the passed-in Array.
ALKMaps.Bounds.fromSize = function( size )
Alternative constructor that builds a new ALKMaps.Bounds from a size
size | {<ALKMaps.Size>|Object} ALKMaps.Size or an object with a ‘w’ and ‘h’ properties. |
{ALKMaps.Bounds} New bounds object built from the passed-in size.
ALKMaps.Bounds.oppositeQuadrant = function( quadrant )
Get the opposite quadrant for a given quadrant string.
quadrant | {String} two character quadrant shortstring |
{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.
Create a cloned instance of this bounds.
clone:function()
Test a two bounds for equivalence.
equals:function( bounds )
{String} String representation of bounds object.
toString:function()
toArray: function( reverseAxisOrder )
toBBOX:function( decimal, reverseAxisOrder )
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()
{ALKMaps.Size} The size of the box.
getSize:function()
{ALKMaps.Pixel} The center of the bounds in pixel space.
getCenterPixel:function()
{ALKMaps.LonLat} The center of the bounds in map space.
getCenterLonLat:function()
Scales the bounds around a pixel or lonlat.
scale: function( ratio, origin )
add:function( x, y )
Extend the bounds to include the point, lonlat, or bounds specified.
extend:function( object )
containsLonLat: function( ll, options )
containsPixel:function( px, inclusive )
contains:function( x, y, inclusive )
Determine whether the target bounds intersects this bounds.
intersectsBounds:function( bounds, options )
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 )
Alternative constructor that builds a new ALKMaps.Bounds from a parameter string
ALKMaps.Bounds.fromString = function( str, reverseAxisOrder )
Alternative constructor that builds a new ALKMaps.Bounds from an array
ALKMaps.Bounds.fromArray = function( bbox, reverseAxisOrder )
Alternative constructor that builds a new ALKMaps.Bounds from a size
ALKMaps.Bounds.fromSize = function( size )
Get the opposite quadrant for a given quadrant string.
ALKMaps.Bounds.oppositeQuadrant = function( quadrant )