wrld.js

Polygon

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

Note that points you pass when creating a polygon shouldn't have an additional last point equal to the first one — it's better to filter out such points.

Creation

Factory Description
L.polygon( <LatLng[]> latlngs, <Polyline options> options? ) Instantiates a polygon object given an array of geographical points and optionally an options object (the same as for Polyline). You can also create a polygon with holes by passing an array of arrays of latlngs, with the first latlngs array representing the exterior ring while the remaining represent the holes inside.

Methods

Polygon has the same options and methods as Polyline, with the following differences:

Method Returns Description
toGeoJSON() Object Returns a GeoJSON representation of the polygon (GeoJSON Polygon Feature).
v0.1.1335