Working with Data
Unfolded's Map SDK allows you to add, remove or replace existing datasets on the map.
Add a new dataset
Using addDataset(...)
function you can pass a new Dataset object that will be added to the map.
Layer will be automaticaly created, if not otherwise selected by setting the autoCreateLayers
parameter to false
.
/**
* Adds a new dataset to the map.
* @param dataset The dataset to add.
* @param options Options applicable when adding a new dataset.
* @returns The dataset that was added.
*/
addDataset(
dataset: DatasetCreationProps, options?: AddDatasetOptions
): Dataset
Parameters
Name Description dataset.id string
(Optional)
Unique identifier of the datasetdataset.label string
(Optional)
Displayable dataset labeldataset.color RGBColor
(Optional)
Color label of the dataset.dataset.fields Field[]
(Optional)
Schema describring the fields of the datasetdataset.data string
(Optional)
JSON string (can be a CSV or GeoJSON formatted data)options.autoCreateLayers boolean
default: true
(Optional)
Iftrue
Studio will attempt to create layers automaticallyoptions.centerMap boolean
default: true
(Optional)
Iftrue
Studio will center the map on the new dataset.
Remove a dataset
In case we want to remove the added dataset, we just need to pass the id
of the dataset to the removeDataset
API function:
removeDataset(id: string)
NOTE: Keep in mind that if a dataset is removed, every layer associated with that dataset will be removed too.
Name Description id string
Unique identifier of the dataset
Expanding the sidebar in Unfolded Studio, we can see that the dataset has been removed and along with it the associated layer(s).