Skip to main content
Version: 1.0.0

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

  • NameDescription
    dataset.id string
    (Optional) Unique identifier of the dataset
    dataset.label string
    (Optional) Displayable dataset label
    dataset.color RGBColor
    (Optional) Color label of the dataset.
    dataset.fields Field[](Optional) Schema describring the fields of the dataset
    dataset.data string(Optional) JSON string (can be a CSV or GeoJSON formatted data)
    options.autoCreateLayers booleandefault: true
    (Optional) If true Studio will attempt to create layers automatically
    options.centerMap booleandefault: true
    (Optional) If true 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.

  • NameDescription
    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).