You are viewing an older version of Mapbox.js. Check out v3.0.1 for the latest.


A class for drawing rectangle overlays on a map. Extends Polygon. Use Map#addLayer to add it to the map.

Usage example

// define rectangle geographical bounds
var bounds = [[54.559322, -5.767822], [56.1210604, -3.021240]];

// create an orange rectangle
L.rectangle(bounds, {color: "#ff7800", weight: 1}).addTo(map);

// zoom the map to the rectangle bounds


Factory Description
L.rectangle( <LatLngBounds> bounds, <Path options> options? ) Instantiates a rectangle object with the given geographical bounds and optionally an options object.


You can use Path methods and additionally the following methods:

Method Returns Description
setBounds( <LatLngBounds> bounds ) this Redraws the rectangle with the passed bounds.