Class: LineString

LineString

Represents a LineString type Geometry.

new LineString(coordinates, optionsopt) [source]

var line = new LineString(
    [
        [121.45942, 31.24123],
        [121.46371, 31.24226],
        [121.46727, 31.23870],
        [121.47019, 31.24145]
    ]
).addTo(layer);
Parameter Type Default Description
coordinates Array.<Coordinate> | Array.<Array.<Number>> coordinates of the line string
options opt Object null construct options defined in LineString
Extends:

Members

  • (constant) options

  • Properties:
    Name Type Default Description
    options opt Object null
    Properties
    Name Type Default Description
    arrowStyle opt String null style of arrow, if not null, arrows will be drawn, possible values: classic
    arrowPlacement opt String vertex-last arrow's placement: vertex-first, vertex-last, vertex-firstlast, point
    symbol Object Path's default symbol
    id opt Boolean null id of the geometry
    visible opt Boolean true whether the geometry is visible.
    editable opt Boolean true whether the geometry can be edited.
    cursor opt String null cursor style when mouseover the geometry, same as the definition in CSS.
    shadowBlur opt Number 0 level of the shadow around the geometry, see MDN's explanation
    shadowColor opt String black color of the shadow around the geometry, a CSS style color
    measure opt String EPSG:4326 the measure code for the geometry, defines measureGeometry how it can be measured.
    draggable opt Boolean false whether the geometry can be dragged.
    dragShadow opt Boolean false if true, during geometry dragging, a shadow will be dragged before geometry was moved.
    dragOnAxis opt Boolean null if set, geometry can only be dragged along the specified axis, possible values: x, y
    Overrides:
    Source:

    Methods

  • setCoordinates(coordinates) [source]

  • Set new coordinates to the line string
    Parameter Type Description
    coordinates Array.<Coordinate> | Array.<Array.<Number>> new coordinates
    Fires:
    Returns:
    LineString: this
  • getCoordinates() [source]

  • Get coordinates of the line string
    Returns:
    Array.<Coordinate>|Array.<Array.<Number>>: coordinates
  • getCenterInExtent(extent) [source]

  • Get center of linestring's intersection with give extent
    const extent = map.getExtent();
     const center = line.getCenterInExtent(extent);
    Parameter Type Description
    extent Extent
    Returns:
    Coordinate: center, null if line doesn't intersect with extent
  • (inherited) animateShow(optionsopt, cbopt) [source]

  • Show the linestring with animation
    line.animateShow({
       duration : 2000,
       easing : 'linear'
     }, function (frame, currentCoord) {
       //frame is the animation frame
       //currentCoord is current coordinate of animation
     });
    Parameter Type Default Description
    options opt Object null animation options
    Properties
    Parameter Type Default Description
    duration opt Number 1000 duration
    easing opt String out animation easing
    cb opt function null callback function in animation, function parameters: frame, currentCoord
    Inherited From:
    Returns:
    LineString: this