Documentation
Reference
2.1.50 (current version)
collection
interactivityModel
Interfaces

geometryEditor.LineString

Extends IGeometryEditor.

The "Polyline" geometry editor.

Constructor | Fields | Events | Methods

Constructor

geometryEditor.LineString(geometry[, options])

Parameters:

ParameterDefault valueDescription
geometry *
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: ILineStringGeometry

"Polyline" geometry.

options

Type: Object

Options for the geometry editor.

options.dblClickHandler

Type: Function

Handler for double-clicking a vertex. Accepts a reference to a model of the vertex being edited. By default, the handler is defined by the function that removes the corresponding vertex.

options.drawingCursor "arrow"

Type: Boolean

The mouse cursor in the mode for adding new vertexes.

options.drawOver true

Type: Boolean

Allows to put points on top of map objects in the mode for adding new vertexes.

options.edgeInteractiveOptions true

Type: Boolean

Allows the intermediate vertices placemarks to use options with postfixes linked to the current state of the placemark. The following postfixes are available:

  • Hover - Options with this given postfix are used when the user hovers over a placemark with the mouse pointer.
  • Drag - Options with this given postfix are used when the user drags a placemark.
Examples of such options: edgeLayoutHover, edgeIconImageSizeActive, edgeIconImageShapeHover, etc. If you do not want to change the options of intermediate vertices placemarks depending on their state, then you will need to disable this option.

options.edgeLayout

Type: Function

Class of the layout for interim placemarks.

options.maxPoints Infinity

Type: Number

The maximum allowable number of vertexes on a polyline.

options.menuManager

Type: Function

Context menu dispatcher for the menu that opens when clicking on a vertex. Accepts two arguments:

  • An array of objects describing the context menu items for this vertex.
  • A reference to a model of the vertex being edited.
The dispatcher can change data in the passed array. Must return an array of objects that describe context menu items.

options.minPoints 0

Type: Number

The maximum allowable number of vertexes on a polyline.

options.useAutoPanInDrawing true

Type: Boolean

Enables autopan of the map when dragging a vertex on the boundary.

options.useMapMarginInDrawing true

Type: Boolean

Whether to use map margins in drawing mode.

options.vertexInteractiveOptions true

Type: Boolean

Allows the vertices placemarks to use options with postfixes linked to the current state of the vertex. The following postfixes are available:

  • Hover - Options with this given postfix are used when the user hovers over a vertex with the mouse pointer.
  • Drag - Options with this given postfix are used when the user drags a vertex.
  • Active - Options with this given postfix are used when the context menu is opened for the vertex.
Examples of such options: vertexLayoutHover, vertexIconImageSizeActive, vertexIconImageShapeHover, etc. If you do not want to change the options of vertices placemarks depending on their state, then you will need to disable this option.

options.vertexLayout

Type: Function

Class of the layout for placemarks on polyline vertexes.

* Mandatory parameter/option.

Fields

NameTypeDescription
eventsIEventManager

Event manager.

Inherited from IEventEmitter.

geometryIGeometry

The geometry being edited.

Inherited from IGeometryEditor.

optionsIOptionManager

Options manager.

Inherited from ICustomizable.

stateIDataManager

Manager for the state of the geometry editor.

Data fields that are available via the "get" and "set" methods:

  • editing - Checks whether editing mode is enabled. Type - Boolean. Default value - false.
  • drawing - Checks whether vertex drawing mode is enabled. Type - Boolean. Default value - false.
  • drawingFrom - Checks how new points are added in drawing mode. Accepts one of two string values: "begin" - points are added at the beginning of the polyline; "end" - points are added at the end. Default value - "end".

Events

NameDescription
beforeedgedrag

Event preceding the "edgedrag" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • pixelOffset - Array of two numbers that describe the pixel offset at this step.
  • edgeModel - Reference to the model of the draggable placemark.
  • globalPixels - Coordinates of the draggable placemark, in global pixel coordinates.
Names of methods that are accessible via Event.callMethod:
  • setPixelOffset - This method is for correcting the value of the pixel offset that will actually be applied. It takes an argument with the new pixel offset in the form of an array of two numbers.
If the Event.preventDefault method is called for this event, a subsequent "edgedrag" event will be canceled.

beforeedgedragstart

Event preceding the "edgedragstart" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • domEvent - Source DOM event (as a DomEvent object), if there is one.
  • edgeModel - Reference to the model of the draggable placemark.
  • globalPixels - Coordinates of the draggable placemark, in global pixel coordinates.
If the Event.preventDefault method is called for this event, any subsequent dragging, as well as the "edgedragstart" event, will be canceled.

beforevertexadd

Event preceding the "vertexadd" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • parentModel - Reference to the parent data model for the vertex being added.
  • vertexIndex - Index of the vertex being added.
  • globalPixels - Coordinates of the vertex being added, in global pixel coordinates.
Names of methods that are accessible via Event.callMethod:
  • setGlobalPixels - Use this method to correct the coordinate values of the added vertex. It takes an argument with the new global pixel coordinates of the vertex as an array of two numbers.
If the Event.preventDefault method is called for this event, a subsequent "vertexadd" event will be canceled.

beforevertexdrag

Event preceding the "vertexdrag" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • pixelOffset - Array of two numbers that describe the pixel offset at this step.
  • vertexModel - Reference to the model of the draggable vertex.
  • globalPixels - Coordinates of the draggable vertex, in global pixel coordinates.
Names of methods that are accessible via Event.callMethod:
  • setPixelOffset - This method is for correcting the value of the pixel offset that will actually be applied. It takes an argument with the new pixel offset in the form of an array of two numbers.
If the Event.preventDefault method is called for this event, a subsequent "vertexdrag" event will be canceled.

beforevertexdragstart

Event preceding the "vertexdragstart" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • domEvent - Source DOM event (as a DomEvent object), if there is one.
  • vertexModel - Reference to the model of the draggable vertex.
  • globalPixels - Coordinates of the draggable vertex, in global pixel coordinates.
If the Event.preventDefault method is called for this event, any subsequent dragging, as well as the"vertexdragstart" event, will be canceled.

beforevertexdraw

Event preceding the "vertexdraw" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • parentModel - Reference to the parent data model for the vertex being added.
  • vertexIndex - Index of the vertex being added.
  • globalPixels - Coordinates of the vertex being added, in global pixel coordinates.
Names of methods that are accessible via Event.callMethod:
  • setGlobalPixels - Use this method to correct the coordinate values of the added vertex. It takes an argument with the new global pixel coordinates of the vertex as an array of two numbers.
If the Event.preventDefault method is called for this event, a subsequent "vertexdraw" event will be canceled.

drawingstart

Enabling the mode for adding new vertexes. Instance of the Event class.

drawingstop

Disabling the mode for adding new vertexes. Instance of the Event class.

edgedrag

Dragging an interim placemark. Instance of the Event class. Names of fields that are available via the Event.get method:

  • pixelOffset - Array of two numbers that describe the pixel offset at this step.
  • edgeModel - Reference to the model of the draggable placemark.
  • globalPixels - Coordinates of the draggable placemark, in global pixel coordinates.

edgedragend

End of dragging an interim placemark. Instance of the Event class. Names of fields that are available via the Event.get method:

  • edgeModel - Reference to the model of the draggable placemark.
  • globalPixels - Coordinates of the draggable placemark, in global pixel coordinates.

edgedragstart

Start of dragging an interim placemark. Instance of the Event class. Names of fields that are available via the Event.get method:

  • domEvent - Source DOM event (as a DomEvent object), if there is one.
  • edgeModel - Reference to the model of the draggable placemark.
  • globalPixels - Coordinates of the draggable placemark, in global pixel coordinates.

editingstart

Enabling the mode for editing vertexes. Instance of the Event class.

editingstop

Disabling the mode for editing vertexes. Instance of the Event class.

framingstart

Enabling the zoom mode. Instance of the Event class.

framingstop

Disabling the zoom mode. Instance of the Event class.

optionschange

Change to the object options.

Inherited from ICustomizable.

statechange

Change to the geometry editor state. Instance of the Event class.

Inherited from IGeometryEditor.

vertexadd

Adding a new vertex. Instance of the Event class. Names of fields that are available via the Event.get method:

  • parentModel - Reference to the parent data model for the vertex that was added.
  • vertexIndex - Index of the vertex that was added.
  • globalPixels - Coordinates of the vertex that was added, in global pixel coordinates.

vertexdrag

Dragging a vertex. Instance of the Event class. Names of fields that are available via the Event.get method:

  • pixelOffset - Array of two numbers that describe the pixel offset at this step.
  • vertexModel - Reference to the model of the draggable vertex.
  • globalPixels - Coordinates of the draggable vertex, in global pixel coordinates.

vertexdragend

End of vertex dragging. Instance of the Event class. Names of fields that are available via the Event.get method:

  • vertexModel - Reference to the model of the draggable vertex.
  • globalPixels - Coordinates of the draggable vertex, in global pixel coordinates.

vertexdragstart

Start of vertex dragging. Instance of the Event class. Names of fields that are available via the Event.get method:

  • domEvent - Source DOM event (as a DomEvent object), if there is one.
  • vertexModel - Reference to the model of the draggable vertex.
  • globalPixels - Coordinates of the draggable vertex, in global pixel coordinates.

vertexdraw

Drawing a new vertex. This event usually precedes the add vertex event, and occurs when the mouse moves and the mode for adding new vertexes is enabled. Based on data passed in this event, guide lines are displayed in vertex drawing mode. Instance of the Event class. Names of fields that are available via the Event.get method:

  • parentModel - Reference to the parent data model for the vertex being added.
  • vertexIndex - Index of the vertex being added.
  • globalPixels - Coordinates of the vertex being added, in global pixel coordinates.

Methods

NameReturnsDescription
getModel()

vow.Promise

Returns the promise object, which is confirmed by the model object at the time it is actually created, or is rejected with one of the following error messages:

  • Canceled - Editing mode is disabled until the model is actually created.
  • Editor wasn't started - Editing mode is not enabled.
.

getModelSync()

geometryEditor.model.RootLineString|null

Returns the editor's data model, or null if it is missing at the time of the call.

getView()

vow.Promise

Returns the promise object, which is confirmed by the representation object at the time it is actually created, or is rejected with one of the following error messages:

  • Canceled - Editing mode is disabled until the representation is actually created.
  • Editor wasn't started - Editing mode is not enabled.
.

getViewSync()

geometryEditor.view.Path|null

Returns the editor's representation, or null if it is missing at the time of the call.

startDrawing()

vow.Promise

Enables vertex drawing mode for a polyline. Enabling occurs asynchronously.

startEditing()

vow.Promise

Enables editing mode. Enabling occurs asynchronously.

startFraming()

vow.Promise

Enables the zoom mode for a polyline. Enabling occurs asynchronously.

stopDrawing()

Disables vertex drawing mode for a polyline.

stopEditing()

Disables editing mode.

stopFraming()

Disables the zoom mode.

Fields details

state

{IDataManager} state

Manager for the state of the geometry editor.

Data fields that are available via the "get" and "set" methods:

  • editing - Checks whether editing mode is enabled. Type - Boolean. Default value - false.
  • drawing - Checks whether vertex drawing mode is enabled. Type - Boolean. Default value - false.
  • drawingFrom - Checks how new points are added in drawing mode. Accepts one of two string values: "begin" - points are added at the beginning of the polyline; "end" - points are added at the end. Default value - "end".

Events details

beforeedgedrag

Event preceding the "edgedrag" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • pixelOffset - Array of two numbers that describe the pixel offset at this step.
  • edgeModel - Reference to the model of the draggable placemark.
  • globalPixels - Coordinates of the draggable placemark, in global pixel coordinates.
Names of methods that are accessible via Event.callMethod:
  • setPixelOffset - This method is for correcting the value of the pixel offset that will actually be applied. It takes an argument with the new pixel offset in the form of an array of two numbers.
If the Event.preventDefault method is called for this event, a subsequent "edgedrag" event will be canceled.

beforeedgedragstart

Event preceding the "edgedragstart" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • domEvent - Source DOM event (as a DomEvent object), if there is one.
  • edgeModel - Reference to the model of the draggable placemark.
  • globalPixels - Coordinates of the draggable placemark, in global pixel coordinates.
If the Event.preventDefault method is called for this event, any subsequent dragging, as well as the "edgedragstart" event, will be canceled.

beforevertexadd

Event preceding the "vertexadd" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • parentModel - Reference to the parent data model for the vertex being added.
  • vertexIndex - Index of the vertex being added.
  • globalPixels - Coordinates of the vertex being added, in global pixel coordinates.
Names of methods that are accessible via Event.callMethod:
  • setGlobalPixels - Use this method to correct the coordinate values of the added vertex. It takes an argument with the new global pixel coordinates of the vertex as an array of two numbers.
If the Event.preventDefault method is called for this event, a subsequent "vertexadd" event will be canceled.

Example:

// Correcting the coordinates of the vertex add event so that they stay within a square with sides that are
// 100 pixels that is centered on the map center.
polyline.editor.events.add(["beforevertexdraw", "beforevertexadd"], function (event) {
    var mapGlobalPixelCenter = geoMap.getGlobalPixelCenter(),
        globalPixels = event.get("globalPixels"),
        pixelBounds = [
            [mapGlobalPixelCenter[0] - 100, mapGlobalPixelCenter[1] - 100],
            [mapGlobalPixelCenter[0] + 100, mapGlobalPixelCenter[1] + 100]
        ];
    event.callMethod("setGlobalPixels", [
        Math.max(Math.min(globalPixels[0], pixelBounds[1][0]), pixelBounds[0][0]),
        Math.max(Math.min(globalPixels[1], pixelBounds[1][1]), pixelBounds[0][1])
    ]);
});

beforevertexdrag

Event preceding the "vertexdrag" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • pixelOffset - Array of two numbers that describe the pixel offset at this step.
  • vertexModel - Reference to the model of the draggable vertex.
  • globalPixels - Coordinates of the draggable vertex, in global pixel coordinates.
Names of methods that are accessible via Event.callMethod:
  • setPixelOffset - This method is for correcting the value of the pixel offset that will actually be applied. It takes an argument with the new pixel offset in the form of an array of two numbers.
If the Event.preventDefault method is called for this event, a subsequent "vertexdrag" event will be canceled.

Example:

// Inverting the offset when dragging the vertex.
polyline.editor.events.add("beforevertexdrag", function (event) {
    var pixelOffset = event.get("pixelOffset");
    event.callMethod("setPixelOffset", [-pixelOffset[0], -pixelOffset[1]]);
});

beforevertexdragstart

Event preceding the "vertexdragstart" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • domEvent - Source DOM event (as a DomEvent object), if there is one.
  • vertexModel - Reference to the model of the draggable vertex.
  • globalPixels - Coordinates of the draggable vertex, in global pixel coordinates.
If the Event.preventDefault method is called for this event, any subsequent dragging, as well as the"vertexdragstart" event, will be canceled.

beforevertexdraw

Event preceding the "vertexdraw" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • parentModel - Reference to the parent data model for the vertex being added.
  • vertexIndex - Index of the vertex being added.
  • globalPixels - Coordinates of the vertex being added, in global pixel coordinates.
Names of methods that are accessible via Event.callMethod:
  • setGlobalPixels - Use this method to correct the coordinate values of the added vertex. It takes an argument with the new global pixel coordinates of the vertex as an array of two numbers.
If the Event.preventDefault method is called for this event, a subsequent "vertexdraw" event will be canceled.

drawingstart

Enabling the mode for adding new vertexes. Instance of the Event class.

drawingstop

Disabling the mode for adding new vertexes. Instance of the Event class.

edgedrag

Dragging an interim placemark. Instance of the Event class. Names of fields that are available via the Event.get method:

  • pixelOffset - Array of two numbers that describe the pixel offset at this step.
  • edgeModel - Reference to the model of the draggable placemark.
  • globalPixels - Coordinates of the draggable placemark, in global pixel coordinates.

edgedragend

End of dragging an interim placemark. Instance of the Event class. Names of fields that are available via the Event.get method:

  • edgeModel - Reference to the model of the draggable placemark.
  • globalPixels - Coordinates of the draggable placemark, in global pixel coordinates.

edgedragstart

Start of dragging an interim placemark. Instance of the Event class. Names of fields that are available via the Event.get method:

  • domEvent - Source DOM event (as a DomEvent object), if there is one.
  • edgeModel - Reference to the model of the draggable placemark.
  • globalPixels - Coordinates of the draggable placemark, in global pixel coordinates.

editingstart

Enabling the mode for editing vertexes. Instance of the Event class.

editingstop

Disabling the mode for editing vertexes. Instance of the Event class.

framingstart

Enabling the zoom mode. Instance of the Event class.

framingstop

Disabling the zoom mode. Instance of the Event class.

vertexadd

Adding a new vertex. Instance of the Event class. Names of fields that are available via the Event.get method:

  • parentModel - Reference to the parent data model for the vertex that was added.
  • vertexIndex - Index of the vertex that was added.
  • globalPixels - Coordinates of the vertex that was added, in global pixel coordinates.

vertexdrag

Dragging a vertex. Instance of the Event class. Names of fields that are available via the Event.get method:

  • pixelOffset - Array of two numbers that describe the pixel offset at this step.
  • vertexModel - Reference to the model of the draggable vertex.
  • globalPixels - Coordinates of the draggable vertex, in global pixel coordinates.

vertexdragend

End of vertex dragging. Instance of the Event class. Names of fields that are available via the Event.get method:

  • vertexModel - Reference to the model of the draggable vertex.
  • globalPixels - Coordinates of the draggable vertex, in global pixel coordinates.

vertexdragstart

Start of vertex dragging. Instance of the Event class. Names of fields that are available via the Event.get method:

  • domEvent - Source DOM event (as a DomEvent object), if there is one.
  • vertexModel - Reference to the model of the draggable vertex.
  • globalPixels - Coordinates of the draggable vertex, in global pixel coordinates.

vertexdraw

Drawing a new vertex. This event usually precedes the add vertex event, and occurs when the mouse moves and the mode for adding new vertexes is enabled. Based on data passed in this event, guide lines are displayed in vertex drawing mode. Instance of the Event class. Names of fields that are available via the Event.get method:

  • parentModel - Reference to the parent data model for the vertex being added.
  • vertexIndex - Index of the vertex being added.
  • globalPixels - Coordinates of the vertex being added, in global pixel coordinates.

Methods details

getModel

{vow.Promise} getModel()

Returns the promise object, which is confirmed by the model object at the time it is actually created, or is rejected with one of the following error messages:

  • Canceled - Editing mode is disabled until the model is actually created.
  • Editor wasn't started - Editing mode is not enabled.
.

getModelSync

Returns the editor's data model, or null if it is missing at the time of the call.

getView

{vow.Promise} getView()

Returns the promise object, which is confirmed by the representation object at the time it is actually created, or is rejected with one of the following error messages:

  • Canceled - Editing mode is disabled until the representation is actually created.
  • Editor wasn't started - Editing mode is not enabled.
.

getViewSync

{geometryEditor.view.Path|null} getViewSync()

Returns the editor's representation, or null if it is missing at the time of the call.

startDrawing

{vow.Promise} startDrawing()

Enables vertex drawing mode for a polyline. Enabling occurs asynchronously.

Returns the promise object, which is confirmed when drawing mode has actually started, or is rejected with one of the following error messages:

  • Canceled - Drawing mode is disabled until it is actually started.
.

startEditing

{vow.Promise} startEditing()

Enables editing mode. Enabling occurs asynchronously.

Returns the promise object, which is confirmed when editing mode has actually started, or is rejected with one of the following error messages:

  • Canceled - Editing mode is disabled until it is actually started.
.

startFraming

{vow.Promise} startFraming()

Enables the zoom mode for a polyline. Enabling occurs asynchronously.

Returns the promise object that is confirmed when zoom mode actually starts.

stopDrawing

{} stopDrawing()

Disables vertex drawing mode for a polyline.

stopEditing

{} stopEditing()

Disables editing mode.

stopFraming

{} stopFraming()

Disables the zoom mode.