Summary
Constructor
new LineFeature(Line, attributes, style)
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Line |
module:geom~Line | 线状几何体。 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
attributes |
Object | 一个对象,用来描述地理要素的非空间属性。 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
style |
Object | 用来描述点状要素及标注在地图上表现形态。当添加到图层上时,如果不指定样式,则采用默认的图层样式。
|
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要素,新要素与原有要素有相同。
Example
let newlineFeature = lineFeature.clone();
-
copyTo(coordinate) → {module:feature~LineFeature}
-
复制一个LineFeature,将得到的LineFeature的地理范围中心变成传参的coordinate。该方法是以要素几何体的中心坐标到目标坐标为基准移动的,复制不影响原来的地理要素。
Parameters:
Name Type Description coordinate
module:basetype~Coordinate 目标地理坐标。
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);