You are viewing an older version of Mapbox.js. Check out v3.1.0 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( <Point> topLeft, <Point> bottomRight ) Creates a Bounds object from two coordinates (usually top-left and bottom-right corners).
L.bounds( <Point[]> points ) 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( <Point> point ) - Extends the bounds to contain the given point.
getCenter() Point Returns the center point of the bounds.
contains( <Bounds> otherBounds ) Boolean Returns true if the rectangle contains the given one.
contains( <Point> point ) Boolean Returns true if the rectangle contains the given point.
intersects( <Bounds> otherBounds ) 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.