feature~Line(coordinates, attributes, symbol)

折线

Summary

Methods:
getNearsPointOnLine

返回线段上距离点最近的线段上的点

getAttributes

获得要素的自定义属性

getCenter

计算折线中心

getCoordinates

获取坐标数组

getId

获取唯一标识

getLength

计算线段长度

getPointsBySegment

根据分段数分割线,返回分段数计算的坐标点数组

getSymbol

获得定义的样式对象

getType

获取要素类型

getVisibility

获得要素的可见性

setAttributes

设置要素的自定义属性

setCoordinates

设置坐标数组

setSymbol

设置样式,与原有样式进行合并

setVisibility

设置 Line 的可见性

Constructor

new Line(coordinates, attributes, symbol)

Parameters:
Name Type Description
coordinates Array.<Array.<Number>>

线的坐标数组[[x,y],[x1,y1]];

attributes Object

自定义属性

symbol Object

线样式定义

Name Type Description
color String

线段颜色,格式为"rgb(255,255,255)"|"#ffffff"格式,默认红色

width Number

线宽

styleType String

线类型,默认:'solid',可选值:可选值:实线"solid"|破折线"dash"|点"dot"|长破折线"long-dash"|长点"lang-dot"|长破折点"long-dash-dot"|短破折"short-dash"|短破折点"short-dash-dot"|短点"short-dot",

lineCap String

折线的终点,或者是不连接其他线段的线段的终点,默认值:'round',可选值:线条的两端为平行的边缘:'butt'|线条的两端添加半圆形线帽'round'|线条的两端添加正方形线帽'square',

lineJoin String

指定折线连接样式,默认值'bevel',可选值:斜角:'bevel'|圆角:'miter'|尖角:'round'

miterLimit Number

斜接连接线宽与线宽的最大比例,默认为2

opacity Number

透明度 默认1

Throws:
RangeError -

数据长度小于2的时候抛出异常

Methods

static getNearsPointOnLine(start, end, coords) → {Array.<number>}

返回线段上距离点最近的线段上的点

Parameters:
Name Type Description
start Array.<number>

线段起点

end Array.<number>

线段终点

coords Array.<Array.<number>>

点坐标

Returns:
Array.<number>

getAttributes() → {Object}

获得要素的自定义属性

Returns:
Object

getCenter() → {Array.<Number>}

计算折线中心

Returns:
Array.<Number>

getCoordinates()

获取坐标数组

getId() → {String}

获取唯一标识

Returns:
String

getLength() → {Number}

计算线段长度

Returns:
Number

getPointsBySegment(segment) → {Array.<Array.<Number>>}

根据分段数分割线,返回分段数计算的坐标点数组

Parameters:
Name Type Description
segment Number

分段数

Returns:
Array.<Array.<Number>>

getSymbol() → {Object}

获得定义的样式对象

Returns:
Object

getType() → {String}

获取要素类型

Returns:
String

getVisibility() → {Boolean}

获得要素的可见性

Returns:
Boolean

setAttributes(attributes)

设置要素的自定义属性

Parameters:
Name Type Description
attributes Object

setCoordinates(coordinates)

设置坐标数组

Parameters:
Name Type Description
coordinates Array.<Array.<Number>>

坐标数组

setSymbol(symbol)

设置样式,与原有样式进行合并

Parameters:
Name Type Description
symbol Object

线样式定义

Name Type Description
width Number

线宽

color String

线段颜色 格式为"rgb(255,255,255)"|"#ffffff"格式

styleType String

线类型,默认:'solid',可选值:可选值:实线"solid"|破折线"dash"|点"dot"|长破折线"long-dash"|长破折点"long-dash-dot"|短破折"short-dash"|短破折点"short-dash-dot"|短点"short-dot",

lineCap String

折线的终点,或者是不连接其他线段的线段的终点,默认值:'round',可选值:线条的两端为平行的边缘:'butt'|线条的两端添加半圆形线帽'round'|线条的两端添加正方形线帽'square',

lineJoin String

指定折线连接样式,默认值'bevel',可选值:斜角:'bevel'|圆角:'miter'|尖角:'round'

miterLimit Number

斜接连接线宽与线宽的最大比例,默认为2

opacity Number

透明度 默认1

Throws:

样式传入错误的话抛出异常

setVisibility(visible)

设置 Line 的可见性

Parameters:
Name Type Description
visible Boolean