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

# geometry.base.Polygon

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

The "Polygon" base geometry.

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

## Constructor {#constructor-summary}

```javascript
geometry.base.Polygon([coordinates[, fillRule]])
```

**Parameters:**

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

Geometry coordinates. ||
|| [`fillRule`](#param-fillRule) | "evenOdd" | Type: String

String ID that defines the polygon fill rule. Accepts one of two values: 
- evenOdd - Algorithm that checks whether a point is located in the fill area by drawing a ray from this point to infinity 	in any direction, and counting the number of contour segments in this shape that are crossed by this ray. If the number is odd, the point is inside it; if even, the point is outside it.
- nonZero - Algorithm that checks whether a point is located in the fill area by drawing a ray from this point to infinity 	in any direction, and checking the points at which a segment of the shape crosses this ray. Starting 	from zero, one is added each time a segment crosses the ray from left to right, and one is subtracted each time a segment 	crosses the ray from right to left. If the result equals zero, the point 	is inside the contour. Otherwise, it is outside it. ||
|#


**Example:**

```javascript
var polygon = new ymaps.geometry.base.Polygon([
    // Outer contour.
    [
        [0, 0], [0, 5], [5, 5], [5, 0], [0, 0]
    ],
    // Inner contour.
    [
        [1, 1], [1, 2], [2, 2], [2, 1], [1, 1]
    ]
]);
```

## Fields {#properties-summary}

#|
|| **Name** | **Type** | **Description** ||
|| [events](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/geometry.base.Polygon.md#events) | [event.Manager](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/event.Manager.md)| Geometry event manager. ||
|#

## Events {#events-summary}

#|
|| **Name** | **Description** ||
|| [change](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#event-change)| Changed coordinates. Instance of the [Event](https://yandex.com/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/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md#get) method: 
- oldCoordinates - Old coordinates
- newCoordinates - New coordinates.
- oldFillRule - Old fill rule.
- newFillRule - New fill rule.

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

## Methods {#methods-summary}

#|
|| **Name** | **Returns** | **Description** ||
|| [contains](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#contains)([position](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#contains-param-position)) | Boolean
| Checks whether the passed point is located inside the polygon.

Inherited from [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#contains). ||
|| [freeze](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#freeze)() | [IFreezable](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md)
| Switches the object to "frozen" mode.

Inherited from [IFreezable](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#freeze). ||
|| [get](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#get)([index](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#get-param-index)) | Number[][]
| Returns coordinates of the contour with the specified index.

Inherited from [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#get). ||
|| [getBounds](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IBaseGeometry.md#getBounds)() | Number[][]\|null
| Returns coordinates of the two opposite corners of the area that surrounds the geometry. The first item in the array is the corner with the smallest coordinate values relative to the rest of the points in the area; the second item is the corner with the largest coordinate values.

Inherited from [IBaseGeometry](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IBaseGeometry.md#getBounds). ||
|| [getChildGeometry](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#getChildGeometry)([index](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#getChildGeometry-param-index)) | [ILinearRingGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILinearRingGeometryAccess.md)
| Creates and returns an [ILinearRingGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILinearRingGeometryAccess.md) object for the specified contour.

Inherited from [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#getChildGeometry). ||
|| [getClosest](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#getClosest)([anchorPosition](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#getClosest-param-anchorPosition)) | Object
| Searches for the point nearest to "anchorPosition" on the polygon contour.

Inherited from [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#getClosest). ||
|| [getCoordinates](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#getCoordinates)() | Number[][][]
| Returns an array of geometry coordinates.

Inherited from [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#getCoordinates). ||
|| [getFillRule](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#getFillRule)() | String
| Returns ID of the fill rule.

Inherited from [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#getFillRule). ||
|| [getLength](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#getLength)() | Integer
| Returns the number of contours in the geometry.

Inherited from [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#getLength). ||
|| [getType](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IBasePolygonGeometry.md#getType)() | String
| Returns the "Polygon" string.

Inherited from [IBasePolygonGeometry](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IBasePolygonGeometry.md#getType). ||
|| [insert](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#insert)([index](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#insert-param-index), [path](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#insert-param-path)) | [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md)
| Adds a new contour with the specified index.

Inherited from [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#insert). ||
|| [isFrozen](https://yandex.com/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/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#isFrozen). ||
|| [remove](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#remove)([index](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#remove-param-index)) | [ILinearRingGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILinearRingGeometryAccess.md)
| Removes the contour with the specified index.

Inherited from [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#remove). ||
|| [set](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#set)([index](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#set-param-index), [path](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#set-param-path)) | [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md)
| Sets coordinates of the contour with the specified index.

Inherited from [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#set). ||
|| [setCoordinates](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#setCoordinates)([coordinates](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#setCoordinates-param-coordinates)) | [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md)
| Sets an array of geometry coordinates.

Inherited from [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#setCoordinates). ||
|| [setFillRule](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#setFillRule)([fillRule](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#setFillRule-param-fillRule)) | [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md)
| Sets the polygon's fill rule.

Inherited from [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#setFillRule). ||
|| [splice](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#splice)([index](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#splice-param-index), [number](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#splice-param-number)) | [ILinearRingGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILinearRingGeometryAccess.md)[]
| Deletes a defined number of contours, starting from the specified index. New contours can be added in place of the deleted ones. Coordinates of the new contours can be passed as additional arguments after the "number" parameter.

Inherited from [IPolygonGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPolygonGeometryAccess.md#splice). ||
|| [unfreeze](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#unfreeze)() | [IFreezable](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md)
| Switches the object to active mode.

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

## Fields details {#field_detail}

### events {#events}

```javascript
{event.Manager} events
```

Geometry event manager.
