--- layout: api title: "v2.0.0 JavaScript Library: L.Rectangle" categories: api version: v2.0.0 permalink: /api/v2.0.0/l-rectangle ---

## 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( <LatLngBounds> bounds, <Path options> options? )` | 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( <LatLngBounds> bounds )` | `this` | Redraws the rectangle with the passed bounds.