Shape class

A helper class that wraps a Geometry or Feature and makes it easy to update and maintain.

Extends

Constructors

Shape(atlas.data.Geometry, string | number, any)

Constructs a Shape object and initializes it with the specified Geometry, ID, and properties.

Shape(Feature<atlas.data.Geometry, any>)

Constructs a Shape object and initializes it with the specified Feature.

Methods

addProperty(string, any)

Adds or updates an existing property value in the shape.

getBounds()

Gets the bounding box of the shape

getCircleCoordinates()

If the shape is a circle, this gets its coordinates. Otherwise returns null.

getCoordinates()

Gets the coordinates of the shape.

getId()

Gets the id of the shape.

getProperties()

Gets the properties of the shape.

getType()

Returns a string indicating the type of geometry this shape contains.

isCircle()

Indicates if the contained shape is a Circle, defined by the extended GeoJSON specification supported by Azure Maps. Extended Spec

isRectangle()

Indicates if the contained shape is a Rectangle, defined by the extended GeoJSON specification supported by Azure Maps. Extended Spec

setCoordinates(Position | Position[] | Position[][] | Position[][][])

Updates the coordinates of the shape

setProperties(any)

Sets the properties on the shape. Overwrites all existing properties.

toJson()

Returns a GeoJSON feature that represents the shape.

Constructor Details

Shape(atlas.data.Geometry, string | number, any)

Constructs a Shape object and initializes it with the specified Geometry, ID, and properties.

new Shape(data: atlas.data.Geometry, id?: string | number, properties?: any)

Parameters

data
Geometry

a Geometry object

id

string | number

a unique id that the user assigns to the shape. If not provided, a unique id value will be assigned to it.

properties

any

User defined properties for the shape.

Shape(Feature<atlas.data.Geometry, any>)

Constructs a Shape object and initializes it with the specified Feature.

new Shape(data: Feature<atlas.data.Geometry, any>)

Parameters

data

Feature<Geometry, any>

a Geometry object

Method Details

addProperty(string, any)

Adds or updates an existing property value in the shape.

function addProperty(key: string, value: any)

Parameters

key

string

value

any

getBounds()

Gets the bounding box of the shape

function getBounds(): BoundingBox

Returns

getCircleCoordinates()

If the shape is a circle, this gets its coordinates. Otherwise returns null.

function getCircleCoordinates(): Position[]

Returns

getCoordinates()

Gets the coordinates of the shape.

function getCoordinates(): Position | Position[] | Position[][] | Position[][][]

Returns

Position | Position[] | Position[][] | Position[][][]

getId()

Gets the id of the shape.

function getId(): string | number

Returns

string | number

getProperties()

Gets the properties of the shape.

function getProperties(): any

Returns

any

getType()

Returns a string indicating the type of geometry this shape contains.

function getType(): string

Returns

string

isCircle()

Indicates if the contained shape is a Circle, defined by the extended GeoJSON specification supported by Azure Maps. Extended Spec

function isCircle(): boolean

Returns

boolean

isRectangle()

Indicates if the contained shape is a Rectangle, defined by the extended GeoJSON specification supported by Azure Maps. Extended Spec

function isRectangle(): boolean

Returns

boolean

setCoordinates(Position | Position[] | Position[][] | Position[][][])

Updates the coordinates of the shape

function setCoordinates(coords: Position | Position[] | Position[][] | Position[][][])

Parameters

coords

Position | Position[] | Position[][] | Position[][][]

Point: Position, LineString: Position[], Polygon: Position[][], MultiPoint: Position[], MultiLineString: Position[][], MultiPolygon: Position[][]

setProperties(any)

Sets the properties on the shape. Overwrites all existing properties.

function setProperties(properties: any)

Parameters

properties

any

toJson()

Returns a GeoJSON feature that represents the shape.

function toJson(): Feature<atlas.data.Geometry, any>

Returns