Summary
Methods:
clone |
克隆一个线符号对象。 |
getAntiAliasing |
获取该线的抗锯齿状态 |
getCapPtCount |
获取线端点或连接处的样式为round时,构成round圆弧的点的数量 |
getColor |
获取颜色值。 |
getDashPixelLength |
获取虚线的片段长度 |
getDashRatio |
获取虚线样式中:实线部分和虚线部分的比例。 |
getLineCap |
获取线端头形状。 |
getLineJoin |
获取连接处的形状。 |
getLineOffset |
获取线的偏移。 |
getLineStyle |
获取线型类型。 |
getMiterLimit |
获取尖角的最大斜接距离。 |
getRenderMode |
获取宽线渲染模式。 |
getWidth |
获取线宽,单位是像素。 |
setAntiAliasing |
设置线抗锯齿状态 |
setCapPtCount |
设置线端点或连接处的样式为round时,构成round圆弧的点的数量 |
setColor |
设置线的颜色值。 |
setDashPixelLength |
设置虚线的片段长度,像素单位,默认20 |
setDashRatio |
设置虚线样式中:实线部分和虚线部分的比例,可以包括两段实线和两段虚线。 |
setLineCap |
设置线端头的形状。 |
setLineJoin |
设置线的连接处的形状。 |
setLineOffset |
设置线的偏移。 |
setLineStyle |
设置线型类型。 |
setMiterLimit |
设置尖角的最大斜接距离,仅当线连接处样式为miter时,才起作用。 |
setRenderMode |
设置宽线渲染模式。 |
setWidth |
设置线的宽度,单位是像素。 |
Constructor
new LineSymbol(options)
构造函数。多边形内部描边线样式仅支持单个颜色、宽度值、实虚线设置
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
|
Example
let lineSymbol = new hmap.style.LineSymbol({
color:new hmap.style.Color(0,0,200,1),//线的颜色值
lineCap:"square",//线端头形状"butt”、“square"、"round"
lineJoin:"bevel",//线连接处形状"bevel"平角、 “miter"尖角、"round"圆角
lineStyle:"solid",//线型,包括‘solid’和‘dash’两种,默认为实线
lineOffset:new hmap.basetype.Offset(3, 3),//线的偏移量,单位为像素,默认在X、Y方向偏移量均为0。
width:5//线的像素宽度,默认为1个像素
});
Methods
-
clone() → {module:style~LineSymbol}
-
克隆一个线符号对象。
Example
let newLineSymbol = lineSymbol.clone();
-
getAntiAliasing() → {boolean|*}
-
获取该线的抗锯齿状态
Returns:
boolean | * -
getCapPtCount() → {Number}
-
获取线端点或连接处的样式为round时,构成round圆弧的点的数量
Returns:
Number -
getColor() → {module:style~Color}
-
获取颜色值。
Example
let color = lineSymbol.getColor();
-
getDashPixelLength() → {Number}
-
获取虚线的片段长度
Returns:
Number -
getDashRatio() → {Array.<Number>}
-
获取虚线样式中:实线部分和虚线部分的比例。
Returns:
Array.<Number> -比例值
Example
let dashRatio = lineSymbol.getDashRatio();
-
getLineCap() → {String}
-
获取线端头形状。
Returns:
String -"butt”、“square"、"round"三者之一。
Example
let lineCap = lineSymbol.getLineCap();
-
getLineJoin() → {String}
-
获取连接处的形状。
Returns:
String -表示连接处形状的字符串。
Example
let lineJoin = lineSymbol.getLineJoin();
-
getLineOffset() → {module:basetype~Offset}
-
获取线的偏移。
Example
let lineOffset = lineSymbol.getLineOffset();
-
getLineStyle() → {String}
-
获取线型类型。
Returns:
String -表示线型的字符串。
Example
let lineStyle = lineSymbol.getLineStyle();
-
getMiterLimit() → {Number}
-
获取尖角的最大斜接距离。
Returns:
Number -尖角的最大斜接距离。
Example
let miterLimit = lineSymbol.getMiterLimit();
-
getRenderMode() → {String|string|*}
-
获取宽线渲染模式。
Returns:
String | string | * -
getWidth() → {Number}
-
获取线宽,单位是像素。
Returns:
Number -线宽
Example
let width = lineSymbol.getWidth();
-
setAntiAliasing(value)
-
设置线抗锯齿状态
Parameters:
Name Type Description value
Boolean 设置线抗锯齿状态
-
setCapPtCount(n) → {Number}
-
设置线端点或连接处的样式为round时,构成round圆弧的点的数量
Parameters:
Name Type Description n
Number 构成round圆弧的点的数量。值越大,圆弧越平滑,但是计算量和内存占用量越大,建议在表现和性能之间进行平衡。
Returns:
Number -返回构成round圆弧的点的数量
-
setColor(color) → {module:style~Color}
-
设置线的颜色值。
Parameters:
Name Type Description color
module:style~Color 线的颜色值。
Example
let color = new hmap.style.Color(255,0,0,1); let lineColor = lineSymbol.setColor(color);
-
setDashPixelLength(length)
-
设置虚线的片段长度,像素单位,默认20
Parameters:
Name Type Description length
Number Throws:
当参数为非大于0的整数时,抛出错误:"LineSymbol-setDashPixelLength:parameter dashPixelLength must be an Integer more than zero"
-
setDashRatio(dashRatio) → {Array.<Number>}
-
设置虚线样式中:实线部分和虚线部分的比例,可以包括两段实线和两段虚线。
Parameters:
Name Type Description dashRatio
Array.<Number> 比例值,长度为4,依次代表实线、虚线、实线、虚线部分的占比,如果数组后两个元素均为0,则实线部分和虚线部分比例均依据数组前两个元素确定。
Throws:
当参数不是数组,或者数组长度不是4,或者数组元素存在非数字以及无穷大数字的情况下,抛出异常:"LineSymbol-setDashRatio:parameter dashRatio must be an Array of length four, and the array elements must be numbers that are not infinity"
Returns:
Array.<Number> -线样式中实线和虚线部分的比例
Example
lineSymbol.setDashRatio([2,1,3,2]);
-
setLineCap(lineCap) → {String}
-
设置线端头的形状。
Parameters:
Name Type Description lineCap
String 线端头形状,合法值是butt、square、round之一。当启用抗锯齿时,无论传入参数是什么,效果都是butt平头。
Throws:
当参数不合法时,抛出异常:"LineSymbol:lineCap should be 'square', or 'butt', or 'round'"。
Returns:
String -返回修改后的线端头形状。
Example
let lineCap = lineSymbol.setLineCap("butt");
-
setLineJoin(lineJoin) → {String}
-
设置线的连接处的形状。
Parameters:
Name Type Description lineJoin
String 线连接处形状,合法值包括bevel(平角)、miter(尖角)、round(圆角)。当启用抗锯齿时,无论传入参数是什么,效果都是bevel平角。
Throws:
当参数不合法时,抛出异常:"LineSymbol:lineJoin should be 'bevel' or 'miter' or 'round'"。
Returns:
String -返回设置值。
Example
let lineJoin = lineSymbol.setLineJoin("bevel");
-
setLineOffset(lineOffset) → {module:basetype~Offset}
-
设置线的偏移。
Parameters:
Name Type Description lineOffset
module:basetype~Offset 偏移量,单位为像素。
Throws:
当参数类型不是Offset时,抛出异常:"LineSymbol:invalid parameter, must be instance of Offset"
Example
let lineOffset = lineSymbol.setLineOffset(new hmap.basetype.Offset(60,10,0));
-
setLineStyle(lineStyle) → {String}
-
设置线型类型。
Parameters:
Name Type Description lineStyle
String 线型,默认为实线solid。可供选择的线型有:dash(虚线)和solid(实线)。
Throws:
当参数不是dash和和solid时,抛出异常:"LineSymbol:lineStyle should be 'dash' or 'solid'"。
Returns:
String -返回修改后的线型类型。
Example
let lineStyle = lineSymbol.setLineStyle("dash");
-
setMiterLimit(miterLimit)
-
设置尖角的最大斜接距离,仅当线连接处样式为miter时,才起作用。
Parameters:
Name Type Description miterLimit
Number 尖角的最大斜接距离
Throws:
当参数不是数字,或者是无穷大的数字时,抛出异常:"LineSymbol:miterLimit should be number that is not infinity"。
Example
let miterLimit = lineSymbol.setMiterLimit(12);
-
setRenderMode(mode) → {String}
-
设置宽线渲染模式。
Parameters:
Name Type Description mode
String 宽线的渲染模式,可以是both(两侧渲染)、left(左侧渲染)或right(右侧渲染)。
Returns:
String -返回修改后的宽线的渲染模式。
-
setWidth(width) → {Number}
-
设置线的宽度,单位是像素。
Parameters:
Name Type Description width
Number 线的宽度。大于等于0。
Throws:
当参数为非正整数时,抛出类型错误:"LineSymbol:width should be number and not less zero"
Returns:
Number -返回修改后的线宽值。
Example
let width = lineSymbol.setWidth(5);