DataSource class

A data source class that makes it easy to manage shapes data that will be displayed on the map. A data source must be added to a layer before it is visible on the map. The DataSource class may be used with the SymbolLayer, LineLayer, PolygonLayer, BubbleLayer, and HeatMapLayer.

Extends

Constructors

DataSource(string, DataSourceOptions)

A data source class that makes it easy to manage shapes data that will be displayed on the map. A data source must be added to a layer before it is visible on the map. The DataSource class may be used with the SymbolLayer, LineLayer, PolygonLayer, BubbleLayer, and HeatMapLayer.

Methods

add(FeatureCollection | Feature<atlas.data.Geometry, any> | atlas.data.Geometry | GeometryCollection | Shape | Array<><>data.Geometry, any> | atlas.data.Geometry | Shape>, number)

Adds shapes to the data source. GeoJSON objects will be wrapped within a Shape class to make them easier to manage. Optionally specify an index to insert the feature between other shapes/features in the layers.

clear()

Removes all data in the data source.

dispose()

Cleans up any resources this object is consuming.

getClusterChildren(number)

Retrieves the children of the given cluster on the next zoom level. This may be a combination of shapes and sub-clusters. The sub-clusters will be features with properties matching ClusteredProperties.

getClusterExpansionZoom(number)

Calculates a zoom level at which the cluster will start expanding or break apart.

getClusterLeaves(number, number, number)

Retrieves shapes that are within the cluster.

getId()

Gets the id of the data source

getOptions()

Gets the options used by the data source.

getShapeById(string)

Retrieves a shape with the specified id. If no shape with the specified id is contained in the data source, null will be return.

getShapes(Expression)

Returns all shapes that are in the DataSource and which satisfy the specified filter expression.

importDataFromUrl(string)

Downloads a GeoJSON document and imports its data into the data source. The GeoJSON document must be on the same domain or accessible using CORS.

remove(number | string | Shape | Feature<atlas.data.Geometry, any>)

Removes a shape from the data source. If a string is passed in, it is assumed to be an id. If a number is passed in, removes the shape at that index.

setOptions(DataSourceOptions)

Sets the data source options. The data source will retain its current values for any option not specified in the supplied options.

setShapes(FeatureCollection | Array<Feature<>data.Geometry, any> | atlas.data.Geometry | Shape>)

Overwrites all shapes in the data source with the new array of shapes.

toJson()

Returns a GeoJSON FeatureCollection which contains all the shape data that is in the data source.

Constructor Details

DataSource(string, DataSourceOptions)

A data source class that makes it easy to manage shapes data that will be displayed on the map. A data source must be added to a layer before it is visible on the map. The DataSource class may be used with the SymbolLayer, LineLayer, PolygonLayer, BubbleLayer, and HeatMapLayer.

new DataSource(id?: string, options?: DataSourceOptions)

Parameters

id
string

a unique id that the user assigns to the data source. If this is not specified, then the data source will automatically be assigned an id.

options
DataSourceOptions

the options for the data source.

Method Details

add(FeatureCollection | Feature<atlas.data.Geometry, any> | atlas.data.Geometry | GeometryCollection | Shape | Array<><>data.Geometry, any> | atlas.data.Geometry | Shape>, number)

Adds shapes to the data source. GeoJSON objects will be wrapped within a Shape class to make them easier to manage. Optionally specify an index to insert the feature between other shapes/features in the layers.

function add(data: FeatureCollection | Feature<atlas.data.Geometry, any> | atlas.data.Geometry | GeometryCollection | Shape | Array<Feature<atlas.data.Geometry, any> | atlas.data.Geometry | Shape>, index?: number)

Parameters

index
number

clear()

Removes all data in the data source.

function clear()

dispose()

Cleans up any resources this object is consuming.

function dispose()

getClusterChildren(number)

Retrieves the children of the given cluster on the next zoom level. This may be a combination of shapes and sub-clusters. The sub-clusters will be features with properties matching ClusteredProperties.

function getClusterChildren(clusterId: number)

Parameters

clusterId
number

Returns

Promise<Array<Feature<Geometry, ClusteredProperties | any> | Shape>>

getClusterExpansionZoom(number)

Calculates a zoom level at which the cluster will start expanding or break apart.

function getClusterExpansionZoom(clusterId: number)

Parameters

clusterId
number

Returns

Promise<number>

getClusterLeaves(number, number, number)

Retrieves shapes that are within the cluster.

function getClusterLeaves(clusterId: number, limit: number, offset: number)

Parameters

clusterId
number
limit
number

The maximum number of features to return. Set to Infinity to return all shapes.

offset
number

The number of shapes to skip. Allows you to page through the shapes in the cluster.

Returns

Promise<Array<Feature<Geometry, any> | Shape>>

getId()

Gets the id of the data source

function getId()

Returns

string

getOptions()

Gets the options used by the data source.

function getOptions()

Returns

getShapeById(string)

Retrieves a shape with the specified id. If no shape with the specified id is contained in the data source, null will be return.

function getShapeById(id: string)

Parameters

id
string

The id of the shape to return.

Returns

getShapes(Expression)

Returns all shapes that are in the DataSource and which satisfy the specified filter expression.

function getShapes(filter?: Expression)

Parameters

filter
Expression

a filter that will limit the query

Returns

Shape[]

importDataFromUrl(string)

Downloads a GeoJSON document and imports its data into the data source. The GeoJSON document must be on the same domain or accessible using CORS.

function importDataFromUrl(url: string)

Parameters

url
string

Returns

Promise<void>

remove(number | string | Shape | Feature<atlas.data.Geometry, any>)

Removes a shape from the data source. If a string is passed in, it is assumed to be an id. If a number is passed in, removes the shape at that index.

function remove(shape: number | string | Shape | Feature<atlas.data.Geometry, any>)

Parameters

shape
number | string | azure-maps-control.atlas.Shape | azure-maps-control.atlas.data.Feature<azure-maps-control.atlas.data.Geometry, any>

The shape, shape id, or feature to be removed

setOptions(DataSourceOptions)

Sets the data source options. The data source will retain its current values for any option not specified in the supplied options.

function setOptions(options: DataSourceOptions)

Parameters

options
DataSourceOptions

the DataSourceOptions to be set

setShapes(FeatureCollection | Array<Feature<>data.Geometry, any> | atlas.data.Geometry | Shape>)

Overwrites all shapes in the data source with the new array of shapes.

function setShapes(shape: FeatureCollection | Array<Feature<atlas.data.Geometry, any> | atlas.data.Geometry | Shape>)

Parameters

shape
FeatureCollection | Array<Feature<Geometry, any> | Geometry | Shape>

the new shapes to update

toJson()

Returns a GeoJSON FeatureCollection which contains all the shape data that is in the data source.

function toJson()

Returns