feature~LineFeature(Line, attributes, style)

线地理要素类。

Summary

Methods:
clone

克隆一个新的LineFeature要素,新要素与原有要素有相同。

copyTo

复制一个LineFeature,将得到的LineFeature的地理范围中心变成传参的coordinate。该方法是以要素几何体的中心坐标到目标坐标为基准移动的,复制不影响原来的地理要素。

getStyle

获取线状要素的样式。

setStyle

设置地理要素的样式。该要素原有的样式会被给出的样式替代。

Constructor

new LineFeature(Line, attributes, style)

Parameters:
Name Type Description
Line module:geom~Line

线状几何体。

attributes Object

一个对象,用来描述地理要素的非空间属性。

style Object

用来描述点状要素及标注在地图上表现形态。当添加到图层上时,如果不指定样式,则采用默认的图层样式。

Name Type Description
line Object

用来描述线状要素样式。

Name Type Description
color Array.<Number>

线的颜色,默认值为[255, 255, 255, 1]。

width Number

线的像素宽度,默认为1个像素。

dash Array.<Number>

虚线样式,由4个元素组成的数组,依次描述一个虚线单元中线段、间距、线段、间距占虚线单元长度的比例。

outlineWidth Array.<Number>

线边框的像素宽度。

outlineColor Number

线边框的像素宽度。

lineCap String

线端头的形状,包括'butt'(平头)、'square'(方头)、'round'(圆头),默认为'butt'。

lineJoin Number

线连接处的形状。包括'bevel'(平角)、'miter'(尖角)、'round'(圆角),默认为'bevel'。

antiAliasing Array.<Number>

是否开启抗锯齿,默认为false。如果开启抗锯齿,线的端头、拐点强制设置为butt、bevel。

label Object

用来描述线状要素的文本符号样式。

Name Type Description
text String

文本符号的内容。

fontWeight String

文本符号的字体粗细,默认值为'normal'。其他可选值为‘bold’和'bolder'。

fontColor Array.<Number>

文本符号的字体颜色,默认值为[255, 255, 255, 1]。其他可选值为‘bold’和'bolder'。

fontSize Number

文本符号的字体大小,默认值为20。

fontStyle Number

文本符号的字体样式,默认是“normal”,可取的值包括“normal”、“italic”、“oblique”。

fontFace String

字体族 与ccs中的font-family相同。默认值为'Microsoft YaHei'。

haloColor String

字体描边颜色,默认为完全透明的白色。

haloWidth Array.<Number>

描边的宽度,单位为像素,默认为0。

Example
let coord = new hmap.basetype.Coordinate(120,30,0);
let point1 = new hmap.geom.Point(coord);
let point2 = new hmap.geom.Point(coord);
let line = new hmap.geom.Line([point1,point2]);
const style = {
              line: {
                  color: [250, 124, 40, 1],
                  width: 10,
                  outlineWidth: 4,
                  outlineColor: [155, 0, 40, 1],
                  lineCap: 'round',//平头、方头、圆头
                  dash: [10,10,10,10],
                  lineJoin: 'bevel',//平角、尖角、圆角
                  ifDash: 1,
                  antiAliasing:true
              },
              label: {
                  text: '闭合线注记',
                  fontSize: 20,
                  fontColor: [255, 225, 255, 1],
                  fontWeight: 'normal',
                  haloColor: [0, 0, 0, 1],
                  haloWidth: 2,
              }
          }
let feature = new hmap.feature.Linefeature(line,null,style);

Methods

clone() → {module:feature~LineFeature}

克隆一个新的LineFeature要素,新要素与原有要素有相同。

Returns:
module:feature~LineFeature -

新的地理要素

Example
let newlineFeature = lineFeature.clone();

copyTo(coordinate) → {module:feature~LineFeature}

复制一个LineFeature,将得到的LineFeature的地理范围中心变成传参的coordinate。该方法是以要素几何体的中心坐标到目标坐标为基准移动的,复制不影响原来的地理要素。

Parameters:
Name Type Description
coordinate module:basetype~Coordinate

目标地理坐标。

Returns:
module:feature~LineFeature -

新地理要素

Example
let coordinate = new hmap.basetype.Coordinate(121,31,0);
let result = lineFeature.copyTo(coordinate);

getStyle() → {object}

获取线状要素的样式。

Returns:
object -

样式

Example
let style = LineFeature.getStyle();

setStyle(样式)

设置地理要素的样式。该要素原有的样式会被给出的样式替代。

Parameters:
Name Type Description
样式 object
Example
LineFeature.setStyle(style);