---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md
  - https://yandex.com.tr/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/ILineStringGeometryAccess.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com.tr/dev/jsapi-v2-1/doc/en/llms.txt

# ILineStringGeometryAccess

Extends [IFreezable](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md).

Interface for access to the "Polyline" geometry.

[Constructor](#constructor-summary) | [Fields](#properties-summary) | [Events](#events-summary) | [Methods](#methods-summary)

## Constructor {#constructor-summary}

```javascript
ILineStringGeometryAccess()
```

## Fields {#properties-summary}

#|
|| **Name** | **Type** | **Description** ||
|| [events](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#events) | [IEventManager](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IEventManager.md) | Event manager for the object.

Inherited from [IFreezable](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#events). ||
|#

## Events {#events-summary}

#|
|| **Name** | **Description** ||
|| [change](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#event-change) | Changed coordinates. Instance of the [Event](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. Names of fields that are available via the [Event.get](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md#get) method: 
- oldCoordinates - Old coordinates
- newCoordinates - New coordinates. ||
|#

## Methods {#methods-summary}

#|
|| **Name** | **Returns** | **Description** ||
|| [freeze](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#freeze)() | [IFreezable](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md) | Switches the object to "frozen" mode.

Inherited from [IFreezable](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#freeze). ||
|| [get](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#get)([index](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#get-param-index)) | Number[] | Returns coordinates of the point with the specified index. ||
|| [getChildGeometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#getChildGeometry)([index](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#getChildGeometry-param-index)) | [IPointGeometryAccess](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPointGeometryAccess.md) | Creates and returns an [IPointGeometryAccess](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPointGeometryAccess.md) object for the specified vertex on the polyline. ||
|| [getClosest](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#getClosest)([anchorPosition](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#getClosest-param-anchorPosition)) | Object | Searches for a point on the polyline closest to the anchorPosition. ||
|| [getCoordinates](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#getCoordinates)() | Number[][] | Returns an array of geometry coordinates. ||
|| [getLength](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#getLength)() | Integer | Returns the number of points in the geometry. ||
|| [insert](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#insert)([index](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#insert-param-index), [coordinates](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#insert-param-coordinates)) | [ILineStringGeometryAccess](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md) | Adds a new point with the specified index. ||
|| [isFrozen](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#isFrozen)() | Boolean | Returns true if the object is in "frozen" mode, otherwise false.

Inherited from [IFreezable](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#isFrozen). ||
|| [remove](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#remove)([index](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#remove-param-index)) | Number[] | Removes the point with the specified index. ||
|| [set](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#set)([index](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#set-param-index), [coordinates](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#set-param-coordinates)) | [ILineStringGeometryAccess](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md) | Sets coordinates of the point with the specified index. ||
|| [setCoordinates](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#setCoordinates)([coordinates](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#setCoordinates-param-coordinates)) | [ILineStringGeometryAccess](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md) | Sets an array of geometry coordinates. ||
|| [splice](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#splice)([index](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#splice-param-index), [number](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILineStringGeometryAccess.md#splice-param-number)) | Number[][] | Deletes a defined number of points, starting from the specified index. New points can be added in place of the deleted ones. Coordinates of the new points can be passed as additional arguments after the "number" parameter. ||
|| [unfreeze](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#unfreeze)() | [IFreezable](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md) | Switches the object to active mode.

Inherited from [IFreezable](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#unfreeze). ||
|#

## Events details {#event_detail}

### change {#change}

Changed coordinates. Instance of the [Event](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. Names of fields that are available via the [Event.get](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md#get) method: 
- oldCoordinates - Old coordinates
- newCoordinates - New coordinates.

## Methods details {#method_detail}

### get {#get}

```javascript
{Number[]} get(index)
```

**Returns** coordinates of the point with the specified index.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`index`](#get-param-index)[*](*star) | — | Type: Integer

Index of a point. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Marking the start of the line with a placemark:
map.geoObjects.add(
    new ymaps.Placemark(polyline.geometry.get(0), { iconContent: 'A' })
);
```

### getChildGeometry {#getChildGeometry}

```javascript
{IPointGeometryAccess} getChildGeometry(index)
```

Creates and returns an [IPointGeometryAccess](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPointGeometryAccess.md) object for the specified vertex on the polyline.

**Returns** the "Point" geometry object that corresponds to the specified endpoint.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`index`](#getChildGeometry-param-index)[*](*star) | — | Type: Integer

Index of an endpoint. ||
|#

\* Mandatory parameter/option.

### getClosest {#getClosest}

```javascript
{Object} getClosest(anchorPosition)
```

Searches for a point on the polyline closest to the anchorPosition.

**Returns** an object with the following fields: 
- position - Point on the polyline closest to "anchorPosition".
- distance - Distance from "anchorPosition" to "position".
- closestPointIndex - Index of the vertex closest to "position".
- nextPointIndex - Index of the vertex that follows "position".
- prevPointIndex - Index of the vertex that precedes "position".
The "nextPointIndex" and "prevPointIndex" fields may be omitted if "position" coincides with one of the polyline vertexes.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`anchorPosition`](#getClosest-param-anchorPosition)[*](*star) | — | Type: Number[]

Coordinates of a point for which the nearest polyline vertex is calculated. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Deleting points from the line when clicked:
myPolyline.events.add('click', function (e) {
    myPolyline.geometry.remove(
        myPolyline.geometry.getClosest(e.get('coords')).closestPointIndex
    );
});
```

### getCoordinates {#getCoordinates}

```javascript
{Number[][]} getCoordinates()
```

**Returns** an array of geometry coordinates.

### getLength {#getLength}

```javascript
{Integer} getLength()
```

**Returns** the number of points in the geometry.

### insert {#insert}

```javascript
{ILineStringGeometryAccess} insert(index, coordinates)
```

Adds a new point with the specified index.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`index`](#insert-param-index)[*](*star) | — | Type: Integer

Index of a point. ||
|| [`coordinates`](#insert-param-coordinates)[*](*star) | — | Type: Number[]

Coordinates of a point. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Adding a new point to the end of the line when the map is clicked.
myMap.events.add('click', function (e) {
    myLineString.insert(myLineString.getLength(), e.get('coords'))
});
```

### remove {#remove}

```javascript
{Number[]} remove(index)
```

Removes the point with the specified index.

**Returns** the coordinates of a deleted point.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`index`](#remove-param-index)[*](*star) | — | Type: Integer

Index of a point. ||
|#

\* Mandatory parameter/option.

### set {#set}

```javascript
{ILineStringGeometryAccess} set(index, coordinates)
```

Sets coordinates of the point with the specified index.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`index`](#set-param-index)[*](*star) | — | Type: Integer

Index of a point. ||
|| [`coordinates`](#set-param-coordinates)[*](*star) | — | Type: Number[]

Coordinates of a point. ||
|#

\* Mandatory parameter/option.

### setCoordinates {#setCoordinates}

```javascript
{ILineStringGeometryAccess} setCoordinates(coordinates)
```

Sets an array of geometry coordinates.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`coordinates`](#setCoordinates-param-coordinates)[*](*star) | — | Type: Number[][]

Geometry coordinates. ||
|#

\* Mandatory parameter/option.

### splice {#splice}

```javascript
{Number[][]} splice(index, number)
```

Deletes a defined number of points, starting from the specified index. New points can be added in place of the deleted ones. Coordinates of the new points can be passed as additional arguments after the "number" parameter.

**Returns** an array of coordinates of deleted points.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`index`](#splice-param-index)[*](*star) | — | Type: Integer

The index to start from for removing and adding points. ||
|| [`number`](#splice-param-number)[*](*star) | — | Type: Integer

The number of deleted points. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Adding a new point to the start of the line when the map is clicked.
myMap.events.add('click', function (e) {
    myLineString.splice(0, 0, myLineString.getLength(), e.get('coords'))
});
```

[*star]: Mandatory parameter/option.