wrld.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( <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.
v0.1.1335