Legacy
Mapbox.js is no longer in active development. To learn more about our newer mapping tools see Mapbox GL JS.
You are viewing an older version of Mapbox.js. Check out v3.3.1 for the latest.
Bounds
Represents a rectangular area in pixel coordinates.
var p1 = L.point(10, 10),
p2 = L.point(40, 60),
bounds = L.bounds(p1, p2);
All Leaflet methods that accept Bounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:
otherBounds.intersects([[10, 10], [40, 60]]);
Creation
Factory | Description |
---|---|
L.bounds(
|
Creates a Bounds object from two coordinates (usually top-left and bottom-right corners). |
L.bounds(
|
Creates a Bounds object defined by the points it contains. |
Properties
Property | Type | Description |
---|---|---|
min |
Point |
The top left corner of the rectangle. |
max |
Point |
The bottom right corner of the rectangle. |
Methods
Method | Returns | Description |
---|---|---|
extend(
|
- | Extends the bounds to contain the given point. |
getCenter() |
Point |
Returns the center point of the bounds. |
contains(
|
Boolean |
Returns true if the rectangle contains the given one. |
contains(
|
Boolean |
Returns true if the rectangle contains the given point. |
intersects(
|
Boolean |
Returns true if the rectangle intersects the given bounds. |
isValid() |
Boolean |
Returns true if the bounds are properly initialized. |
getSize() |
Point |
Returns the size of the given bounds. |