Legacy
Mapbox.js is no longer in active development. To learn more about our newer mapping tools see Mapbox GL JS.
Rectangle
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
map.fitBounds(bounds);
Creation
Factory | Description |
---|---|
L.rectangle(
|
Instantiates a rectangle object with the given geographical bounds and optionally an options object. |
Methods
You can use Path methods and additionally the following methods:
Method | Returns | Description |
---|---|---|
setBounds(
|
this |
Redraws the rectangle with the passed bounds. |