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
.
UnfoldedMap.addDataset(
dataset: string | Dataset, autoCreateLayers = true, centerMap = true
): Promise<boolean>
type Dataset = {
uuid: string;
label: string;
data?: string;
};
Parameters
Name Description dataset.uuid string
Unique identifier of the dataset dataset.label string
(Optional)
Displayable dataset labeldataset.data string
(Optional)
JSON string (can be a CSV or GeoJSON formatted data)autoCreateLayers boolean
default: true
(Optional)
Iftrue
Studio will attempt to create layers automaticallycenterMap boolean
default: true
(Optional)
Iftrue
Studio will center the map on the new dataset.
Add existing dataset
If you are logged in to Studio you can use datasets that have been previously added to your Unfolded Cloud account. All you have to do is pass the uuid
of the previously added dataset.
Remove a dataset
In case we want to remove the added dataset, we just need to pass the uuid of the dataset to the removeDataset
API function:
removeDataset(uuid: string)
NOTE: Keep in mind that if a dataset is removed, every layer associated with that dataset will be removed too.
Name Description uuid 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).