Share via


DataSource class

Classe di origine dati che semplifica la gestione dei dati delle forme che verranno visualizzate sulla mappa. È necessario aggiungere un'origine dati a un livello prima che sia visibile sulla mappa. La classe DataSource può essere usata con SymbolLayer, LineLayer, PolygonLayer, BubbleLayer e HeatMapLayer.

Extends

Costruttori

DataSource(string, DataSourceOptions)

Classe di origine dati che semplifica la gestione dei dati delle forme che verranno visualizzate sulla mappa. È necessario aggiungere un'origine dati a un livello prima che sia visibile sulla mappa. La DataSource classe può essere usata con SymbolLayer, , LineLayerPolygonLayer, BubbleLayere HeatMapLayer.

Metodi

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

Aggiunge forme all'origine dati. Gli oggetti GeoJSON verranno inclusi all'interno di una classe Shape per semplificare la gestione. Facoltativamente, specificare un indice per inserire la caratteristica tra altre forme/caratteristiche nei livelli.

clear()

Rimuove tutti i dati nell'origine dati.

dispose()

Pulisce tutte le risorse utilizzate da questo oggetto.

getClusterChildren(number)

Recupera gli elementi figlio del cluster specificato al livello di zoom successivo. Può trattarsi di una combinazione di forme e sotto cluster. I sotto cluster saranno funzionalità con proprietà corrispondenti a ClusteredProperties.

getClusterExpansionZoom(number)

Calcola un livello di zoom in corrispondenza del quale il cluster inizierà a espandersi o scomporsi.

getClusterLeaves(number, number, number)

Recupera le forme all'interno del cluster.

getOptions()

Ottiene le opzioni utilizzate dall'origine dati.

getShapeById(string | number)

Recupera una forma con l'ID specificato. Se nell'origine dati non è contenuta alcuna forma con l'ID specificato, verrà restituito null.

getShapes()

Restituisce tutte le forme presenti in DataSource.

importDataFromUrl(string)

Scarica un documento GeoJSON e importa i dati nell'origine dati. Il documento GeoJSON deve trovarsi nello stesso dominio o accessibile tramite CORS.

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

Rimuove una o più forme dall'origine dati. Se viene passata una stringa, si presuppone che sia un ID. Se viene passato un numero, rimuove la forma in corrispondenza dell'indice.

removeById(number | string | Array<number | string>)

Rimuove una o più forme dall'origine dati in base al relativo ID.

setOptions(DataSourceOptions)

Imposta le opzioni dell'origine dati. L'origine dati manterrà i valori correnti per qualsiasi opzione non specificata nelle opzioni fornite.

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

Sovrascrive tutte le forme nell'origine dati con la nuova matrice di forme.

toJson()

Restituisce un oggetto FeatureCollection GeoJSON che contiene tutti i dati della forma presenti nell'origine dati.

Metodi ereditati

getId()

Ottiene l'ID dell'origine dati

Dettagli costruttore

DataSource(string, DataSourceOptions)

Classe di origine dati che semplifica la gestione dei dati delle forme che verranno visualizzate sulla mappa. È necessario aggiungere un'origine dati a un livello prima che sia visibile sulla mappa. La DataSource classe può essere usata con SymbolLayer, , LineLayerPolygonLayer, BubbleLayere HeatMapLayer.

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

Parametri

id

string

ID univoco assegnato dall'utente all'origine dati. Se non viene specificato, all'origine dati verrà assegnato automaticamente un ID.

options
DataSourceOptions

opzioni per l'origine dati.

Dettagli metodo

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

Aggiunge forme all'origine dati. Gli oggetti GeoJSON verranno inclusi all'interno di una classe Shape per semplificare la gestione. Facoltativamente, specificare un indice per inserire la caratteristica tra altre forme/caratteristiche nei livelli.

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)

Parametri

index

number

clear()

Rimuove tutti i dati nell'origine dati.

function clear()

dispose()

Pulisce tutte le risorse utilizzate da questo oggetto.

function dispose()

getClusterChildren(number)

Recupera gli elementi figlio del cluster specificato al livello di zoom successivo. Può trattarsi di una combinazione di forme e sotto cluster. I sotto cluster saranno funzionalità con proprietà corrispondenti a ClusteredProperties.

function getClusterChildren(clusterId: number): Promise<Array<Feature<atlas.data.Geometry, ClusteredProperties | any> | Shape>>

Parametri

clusterId

number

Restituisce

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

getClusterExpansionZoom(number)

Calcola un livello di zoom in corrispondenza del quale il cluster inizierà a espandersi o scomporsi.

function getClusterExpansionZoom(clusterId: number): Promise<number>

Parametri

clusterId

number

Restituisce

Promise<number>

getClusterLeaves(number, number, number)

Recupera le forme all'interno del cluster.

function getClusterLeaves(clusterId: number, limit: number, offset: number): Promise<Array<Feature<atlas.data.Geometry, any> | Shape>>

Parametri

clusterId

number

limit

number

Numero massimo di funzionalità da restituire. Impostare su Infinity per restituire tutte le forme.

offset

number

Numero di forme da ignorare. Consente di scorrere le forme nel cluster.

Restituisce

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

getOptions()

Ottiene le opzioni utilizzate dall'origine dati.

function getOptions(): DataSourceOptions

Restituisce

getShapeById(string | number)

Recupera una forma con l'ID specificato. Se nell'origine dati non è contenuta alcuna forma con l'ID specificato, verrà restituito null.

function getShapeById(id: string | number): Shape

Parametri

id

string | number

ID della forma da restituire.

Restituisce

getShapes()

Restituisce tutte le forme presenti in DataSource.

function getShapes(): Shape[]

Restituisce

Shape[]

importDataFromUrl(string)

Scarica un documento GeoJSON e importa i dati nell'origine dati. Il documento GeoJSON deve trovarsi nello stesso dominio o accessibile tramite CORS.

function importDataFromUrl(url: string): Promise<void>

Parametri

url

string

Restituisce

Promise<void>

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

Rimuove una o più forme dall'origine dati. Se viene passata una stringa, si presuppone che sia un ID. Se viene passato un numero, rimuove la forma in corrispondenza dell'indice.

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

Parametri

shape

number | string | Shape | Feature<Geometry, any> | Array<number | string | Shape | Feature<Geometry, any>>

Le forme, gli ID forma o le caratteristiche da rimuovere

removeById(number | string | Array<number | string>)

Rimuove una o più forme dall'origine dati in base al relativo ID.

function removeById(id: number | string | Array<number | string>)

Parametri

id

number | string | Array<number | string>

setOptions(DataSourceOptions)

Imposta le opzioni dell'origine dati. L'origine dati manterrà i valori correnti per qualsiasi opzione non specificata nelle opzioni fornite.

function setOptions(options: DataSourceOptions)

Parametri

options
DataSourceOptions

DataSourceOptions da impostare

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

Sovrascrive tutte le forme nell'origine dati con la nuova matrice di forme.

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

Parametri

shape

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

nuove forme da aggiornare

toJson()

Restituisce un oggetto FeatureCollection GeoJSON che contiene tutti i dati della forma presenti nell'origine dati.

function toJson(): FeatureCollection

Restituisce

Dettagli dei metodi ereditati

getId()

Ottiene l'ID dell'origine dati

function getId(): string

Restituisce

string

Ereditato daSource.getId