--- layout: api title: "v1.6.0 API: L.Polyline" categories: api version: v1.6.0 permalink: /api/v1.6.0/l-polyline ---

## Polyline

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

### Usage example

    // create a red polyline from an arrays of LatLng points
    var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);

    // zoom the map to the polyline
    map.fitBounds(polyline.getBounds());

### Creation

Factory | Description
--- | ---
`L.polyline( <LatLng[]> latlngs, <Polyline options> options? )` | Instantiates a polyline object given an array of geographical points and optionally an options object.

### Options

You can use Path options and additionally the following options:

Option | Type | Default | Description
--- | --- | --- | ---
`smoothFactor` | `Number` | `1.0` | How much to simplify the polyline on each zoom level. More means better performance and smoother look, and less means more accurate representation.
`noClip` | `Boolean` | `false` | Disabled polyline clipping.

### Methods

You can use Path methods and additionally the following methods:

Method | Returns | Description
--- | --- | ---
`addLatLng( <LatLng> latlng )` | `this` | Adds a given point to the polyline.
`setLatLngs( <LatLng[]> latlngs )` | `this` | Replaces all the points in the polyline with the given array of geographical points.
`getLatLngs()` | `LatLng[]` | Returns an array of the points in the path.
`spliceLatLngs( <Number> index, <Number> pointsToRemove, <LatLng> latlng?, … )` | `LatLng[]` | Allows adding, removing or replacing points in the polyline. Syntax is the same as in Array#splice. Returns the array of removed points (if any).
`getBounds()` | `LatLngBounds` | Returns the LatLngBounds of the polyline.
`toGeoJSON()` | `Object` | Returns a GeoJSON representation of the polyline (GeoJSON LineString Feature).