Appearance
Polyline
Polyline
构造折线对象,通过PolylineOptions指定折线样式
Examples
javascript
const polyline = new DiMap.Polyline({
map: map,
path: [
[116.397411, 39.909186],
[116.410886, 39.909186],
[116.410886, 39.924397],
[116.397411, 39.924397]
],
strokeColor: "#FF33FF",
strokeOpacity: 0.2,
strokeWeight: 10,
strokeStyle: "dashed",
lineJoin: "round",
lineCap: "round",
showDir: true,
userData: {
id: "polyline1"
}
})
polyline.show()constructor
Parameters
optionsPolylineOptions 折线选项
setPath
设置path
Parameters
pathArray<LngLatLike>
Returns this
getPath
获取path
Returns Array<LngLatLike>
getLength
获取折线物理长度
Returns number 单位:米
getBounds
获取折线的矩形范围对象
Examples
javascript
const bounds = polyline.getBounds()
map.fitBounds(bounds, {
padding: 100
})Returns LngLatBounds
PolylineOptions
折线属性
Properties
| 参数名 | 必选 | 类型 | 描述 |
|---|---|---|---|
map | 是 | Map | 地图实例 |
path | 是 | Array<LngLatLike> | 折线路径 |
isOutline | 否 | boolean | 是否带描边,默认false |
borderWeight | 否 | number | 描边宽度,默认1 |
outlineColor | 否 | string | 描边颜色,默认#000000 |
strokeColor | 否 | string | 线条颜色,默认#006600 |
strokeOpacity | 否 | number | 线条透明度,默认1 |
strokeWeight | 否 | number | 线条宽度,默认2,单位像素 |
strokeStyle | 否 | "solid" | "dashed" | 线条样式,实线或虚线 |
strokeDasharray | 否 | Array<number> | 自定义虚线样式。实线:[0,0,0];虚线:[10,10](默认);点画线:[10,2,10] |
lineJoin | 否 | "bevel" | "round" | "miter" | 折线拐点连接处的样式,默认尖角(miter),可选:圆角(round),斜角(bevel) |
lineCap | 否 | "round" | "butt" | "square" | 折线两端线帽的样式,默认butt,可选:圆头(round),方头(square) |
userData | 否 | Record<string, any> | 用户自定义数据对象 |
showDir | 否 | boolean | 是否显示方向箭头,默认false |