geometry.Polygon
Extends IPolygonGeometry.
The "Polygon" geometry.
See Polygon
Constructor | Fields | Events | Methods
Constructor
geometry.Polygon([coordinates[, fillRule[, options]]])
Parameters:
Parameter |
Default value |
Description |
[] |
Type: Number[][][] Geometry coordinates. A three-dimensional array of elements that are each two-dimensional coordinates of the polygon contours. The first element describes the outer contour, and the rest describe the inner contours. |
|
"evenOdd" |
Type: String String ID that defines the polygon fill rule. Accepts one of two values:
|
|
— |
Type: Object Geometry options. |
|
"shortestPath" |
Type: String String ID defining the algorithm for recalculating geometry coordinates as pixel coordinates. Accepts one of two values:
|
|
false |
Type: Boolean Enables display using geodesic lines. |
|
"jumpy" |
Type: String Method for calculating pixel coordinates of the shape in cycled projections. This option accepts one of the following values:
|
|
— |
Type: IProjection Projection. |
|
true |
Type: Boolean Enables simplification during rendering of a pixel geometry. |
Example:
// Creating an instance of the polygon geometry (specifying coordinates of vertexes on contours).
var polygonGeometry = new ymaps.geometry.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]
]
]);
// Creating a geo object instance and passing our geometry to the constructor.
var polygonGeoObject = new ymaps.GeoObject({ geometry: polygonGeometry });
// You can also access polygonGeometry via polygonGeoObject.geometry.
Fields
Name |
Type |
Description |
Event manager. Inherited from IEventEmitter. |
||
Options manager. Inherited from ICustomizable. |
Events
Name |
Description |
Changed coordinates. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from IPolygonGeometryAccess. |
|
Map reference changed. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from IGeometry. |
|
Change to the object options. Inherited from ICustomizable. |
|
The pixel geometry changed. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from IGeometry. |
Methods
Name |
Returns |
Description |
Boolean |
Checks whether the passed point is located inside the polygon. Inherited from IPolygonGeometryAccess. |
|
freeze() |
Switches the object to "frozen" mode. Inherited from IFreezable. |
|
Number[][] |
Returns coordinates of the contour with the specified index. Inherited from IPolygonGeometryAccess. |
|
Number[][]|null |
Returns coordinates of the two opposite corners of the area that surrounds the geometry. The first item in the array is the southwest corner of the area; the second item is the northeast corner. Inherited from IGeometry. |
|
Creates and returns an ILinearRingGeometryAccess object for the specified contour. Inherited from IPolygonGeometryAccess. |
||
Object |
Searches for the point nearest to "anchorPosition" on the polygon contour. Inherited from IPolygonGeometryAccess. |
|
Number[][][] |
Returns an array of geometry coordinates. Inherited from IPolygonGeometryAccess. |
|
String |
Returns ID of the fill rule. Inherited from IPolygonGeometryAccess. |
|
Integer |
Returns the number of contours in the geometry. Inherited from IPolygonGeometryAccess. |
|
getMap() |
Map|null |
Returns the current map. Inherited from IGeometry. |
Returns the pixel geometry corresponding to the given geometry, its options, and the map state. Inherited from IGeometry. |
||
getType() |
String |
Returns the "Polygon" string. Inherited from IPolygonGeometry. |
Adds a new contour with the specified index. Inherited from IPolygonGeometryAccess. |
||
isFrozen() |
Boolean |
Returns true if the object is in "frozen" mode, otherwise false. Inherited from IFreezable. |
Removes the contour with the specified index. Inherited from IPolygonGeometryAccess. |
||
Sets coordinates of the contour with the specified index. Inherited from IPolygonGeometryAccess. |
||
Sets an array of geometry coordinates. Inherited from IPolygonGeometryAccess. |
||
Sets the polygon's fill rule. Inherited from IPolygonGeometryAccess. |
||
Sets the map. Inherited from IGeometry. |
||
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. |
||
unfreeze() |
Switches the object to active mode. Inherited from IFreezable. |