你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Shape class
一个帮助程序类,用于包装几何图形或特征,并使其易于更新和维护。
- Extends
构造函数
Shape(atlas. |
构造 Shape 对象,并使用指定的 Geometry、ID 和属性初始化它。 |
Shape(Feature<atlas. |
构造 Shape 对象,并使用指定的功能初始化它。 |
方法
add |
在形状中添加或更新现有属性值。 |
get |
获取形状的边界框 |
get |
如果形状为圆,则获取其坐标。 否则返回 null。 |
get |
获取形状的坐标。 |
get |
获取形状的 ID。 |
get |
获取形状的属性。 |
get |
返回一个字符串,指示此形状包含的几何图形的类型。 |
is |
指示包含的形状是否为圆圈,由Azure Maps支持的扩展 GeoJSON 规范定义。 扩展规格 |
is |
指示包含的形状是否为矩形,由Azure Maps支持的扩展 GeoJSON 规范定义。 扩展规格 |
set |
汇报形状的坐标 |
set |
设置形状上的属性。 覆盖所有现有属性。 |
to |
返回表示形状的 GeoJSON 特征。 |
构造函数详细信息
Shape(atlas.data.Geometry, string | number, any)
构造 Shape 对象,并使用指定的 Geometry、ID 和属性初始化它。
new Shape(data: atlas.data.Geometry, id?: string | number, properties?: any)
参数
- data
- Geometry
Geometry 对象
- id
-
string | number
用户分配给形状的唯一 ID。 如果未提供,则会为其分配唯一 ID 值。
- properties
-
any
用户定义的形状属性。
Shape(Feature<atlas.data.Geometry, any>)
构造 Shape 对象,并使用指定的功能初始化它。
new Shape(data: Feature<atlas.data.Geometry, any>)
参数
方法详细信息
addProperty(string, any)
在形状中添加或更新现有属性值。
function addProperty(key: string, value: any)
参数
- key
-
string
- value
-
any
getBounds()
getCircleCoordinates()
getCoordinates()
获取形状的坐标。
function getCoordinates(): Position | Position[] | Position[][] | Position[][][]
返回
getId()
获取形状的 ID。
function getId(): string | number
返回
string | number
getProperties()
获取形状的属性。
function getProperties(): any
返回
any
getType()
返回一个字符串,指示此形状包含的几何图形的类型。
function getType(): string
返回
string
isCircle()
isRectangle()
setCoordinates(Position | Position[] | Position[][] | Position[][][])
汇报形状的坐标
function setCoordinates(coords: Position | Position[] | Position[][] | Position[][][])
参数
setProperties(any)
设置形状上的属性。 覆盖所有现有属性。
function setProperties(properties: any)
参数
- properties
-
any