Polyline
Extends GeoObject.
Polyline. A geo object with the geometry geometry.LineString.
See GeoObjectgeometry.LineString
Constructor | Fields | Events | Methods
Constructor
Polyline(geometry[, properties[, options]])
Creates a polyline instance.
Parameters:
Parameter |
Default value |
Description |
— |
Type: Number[][]|Object|ILineStringGeometry Coordinates of the vertexes, a hash object with geometery parameters, or a reference to the polyline geometry object. |
|
— |
Type: Object|IDataManager Polyline data. Can be set as a class instance implementing the IDataManager interface, or as a hash. When options are set to default values, the following data fields are interpreted by a geo object:
|
|
— |
Type: Object Polyline options. Using this parameter, you can set options for the polyline itself, as well as for its parts:
|
|
"pointer" |
Type: String Type of cursor over a polyline. |
|
false |
Type: Boolean Checks whether the polyline can be dragged. |
|
true |
Type: Boolean Checks whether the polyline has the "balloon" field. |
|
true |
Type: Boolean Checks whether the polyline has the "hint" field. |
|
false |
Type: Boolean Enables automatically modifying the z-index of the polyline depending on its state. |
|
"default#geoObject" |
Type: String Interactivity model. Available keys and their values are listed in the description of interactivityModel.storage. |
|
"default#polyline" |
Type: String|Function Key identifier from overlay.storage or the overlay class. The generator function accepts three parameters:
|
|
1 |
Type: Number Transparency. |
|
true |
Type: Boolean Checks whether to show the balloon when the polyline is clicked on. |
|
false |
Type: Boolean Checks whether to show an empty balloon when the polyline is clicked on. |
|
false |
Type: Boolean Checks whether to show an empty hint when the mouse pointer hovers over the polyline. |
|
true |
Type: Boolean Checks whether to show an empty hint when the mouse pointer hovers over the polyline. |
|
"areas" |
Type: IPane|String The key of the pane where the polyline overlay is placed. |
|
"0066ffff" |
Type: String|String[] Color of the line or outline. You can set multiple values for a multistroke outline. |
|
1 |
Type: Number|Number[] Transparency of the line or outline. You can set multiple values for a multistroke outline. |
|
— |
Type: String|Object|String[]|Object[] Style of the line or outline. Available styles are listed in the graphics.style.stroke object. |
|
1 |
Type: Number|Number[] Thickness of the line or outline. You can set multiple values for a multistroke outline. |
|
false |
Type: Boolean Enables synchronously adding an overlay to the map. By default, overlays are added to the map asynchronously to prevent the browser from hanging when adding a large number of polylines. However, adding asynchronously does not allow accessing the overlay immediately after adding a polyline to the map. |
|
true |
Type: Boolean When an object is dragged to the edge of the map, the map center changes automatically. Whether to use map margins when automatically shifting the map center with map.margin.Manager. |
|
true |
Type: Boolean Checks polyline visibility. |
|
— |
Type: Number The z-index of a polyline in its normal state. Lowest priority. |
|
— |
Type: Number The z-index of a polyline with an open balloon. Highest priority. |
|
— |
Type: Number The z-index of a polyline that is being dragged. |
|
— |
Type: Number The z-index of a polyline when the mouse pointer is hovering over it. |
* Mandatory parameter/option.
Example:
// Creating a polyline
var polyline = new ymaps.Polyline([
[-80, 60], [-90, 50], [-60, 40], [-80, 60]
], {
hintContent: "Polyline"
}, {
draggable: true,
strokeColor: '#000000',
strokeWidth: 4,
// The first number sets the stroke length. The second number sets the gap length.
strokeStyle: '1 5'
});
// Adding the polyline to the map.
myMap.geoObjects.add(polyline);
// Setting the polyline borders for the map.
myMap.setBounds(polyline.geometry.getBounds());
Fields
Name |
Type |
Description |
Balloon for a geo object. Inherited from GeoObject. |
||
The "Polyline" geometry editor. |
||
Event manager. Inherited from GeoObject. |
||
"Polyline" type of geometry. |
||
Geo object hint. Inherited from GeoObject. |
||
Geo object options manager. Inherited from GeoObject. |
||
Geo object data manager. Inherited from GeoObject. |
||
State of the geo object. Defined by the following fields:
Inherited from GeoObject. |
Events
Name |
Description |
Closing the balloon. Instance of the Event class. Inherited from GeoObject. |
|
Opening a balloon on a geo object. Instance of the Event class. Inherited from GeoObject. |
|
Event preceding the "drag" event. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from GeoObject. |
|
Event preceding the "dragstart" event. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from GeoObject. |
|
Single left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Calls the element's context menu. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Double left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Dragging a geo object. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from GeoObject. |
|
End of geo object dragging. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from GeoObject. |
|
Start of geo object dragging. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from GeoObject. |
|
Change in the state of the editor for the geo object's geometry. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from GeoObject. |
|
Change to the geo object geometry. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from IGeoObject. |
|
Closing the hint. Instance of the Event class. Inherited from GeoObject. |
|
Opening a hint on a geo object. Instance of the Event class. Inherited from GeoObject. |
|
Map reference changed. Data fields:
Inherited from IParentOnMap. |
|
Pressing the mouse button over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Pointing the cursor at the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Moving the cursor off of the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Moving the cursor over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Letting go of the mouse button over an object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
End of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface. Inherited from IDomEventEmitter. |
|
Repeating event during multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields:
Inherited from IDomEventEmitter. |
|
Start of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields:
Inherited from IDomEventEmitter. |
|
Change to the object options. Inherited from ICustomizable. |
|
Change to the geo object overlay. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from IGeoObject. |
|
The parent object reference changed. Data fields:
Inherited from IChild. |
|
Change to the geo object data. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from IGeoObject. |
|
Mouse wheel scrolling. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
Methods
Name |
Returns |
Description |
getMap() |
Returns reference to the map. Inherited from IParentOnMap. |
|
Returns the promise object, which is confirmed by the overlay object at the time it is actually created, or is rejected with an appropriate error message. Inherited from IGeoObject. |
||
IOverlay|null |
The method provides synchronous access to the overlay. Inherited from IGeoObject. |
|
IParentOnMap|null |
Returns link to the parent object, or null if the parent element was not set. Inherited from IChildOnMap. |
|
Sets the parent object. If the null value is passed, the manager element will only be deleted from the current parent object. Inherited from IChildOnMap. |
Fields details
editor
{geometryEditor.LineString} editor
The "Polyline" geometry editor.
geometry
{geometry.LineString} geometry
"Polyline" type of geometry.
Mandatory parameter/option.