Skip to content

Rectangle

Rectangle

构造矩形对象,通过RectangleOptions指定多边形样式

继承Polygon

Examples

javascript
const rectangle = new DiMap.Rectangle({
 map: map,
 bounds: new LngLatBounds([116.397428, 39.90923], [116.417428, 39.93923]),
 strokeColor: '#FF0000',
 strokeWeight: 2,
 strokeOpacity: 1,
 fillColor: '#FF0000',
 fillOpacity: 0.5
})
rectangle.show()

constructor

Parameters

setBounds

设置矩形范围

Parameters

Returns this

getCenter

获取矩形中心点

Returns LngLatLike 矩形中心点

RectangleOptions

矩形选项

Properties

参数名必选类型描述
mapMap地图实例
boundsLngLatBounds矩形的范围
zIndexnumber矩形覆盖物的叠加顺序
strokeColorstring线条颜色,默认值为#00D3FC
strokeOpacitynumber轮廓线透明度,取值范围[0,1],默认为0.9
strokeWeightnumber轮廓线宽度
fillColorstring填充颜色
fillOpacitynumber填充透明度,取值范围[0,1],默认为0.5
heightnumber设置polygon是否离地绘制,默认值为0(需配合extrusionHeight一起使用,且只能≤extrusionHeight)
extrusionHeightnumber设置是否拉伸为的立面体高度值,默认值为0
strokeStyle"solid" | "dashed"轮廓线样式,实线(solid)或虚线(dashed)
strokeDasharrayArray<number>虚线样式,仅在strokeStyle为dashed时有效(IE9+)。取值示例:[0,0,0]实线、[10,10]虚线、[10,2,10]点画线
userDataRecord<string, any>用户自定义数据对象