API Reference

Annotation Functions


addAnnotation

Adds a new annotation to the map.

📝

Note:

You can only add one annotation at most.

Python: add_annotation

addAnnotation: (
  annotation: Partial<Annotation>
) => Annotation;
def add_annotation(
    self, annotation: Union[AnnotationCreationProps, dict]
) -> Optional[Annotation]

Javascript

Arguments

ArgumentTypeDescription
[annotation]AnnotationThe annotation to add to the map.

Returns

Widget map only.

Returns the Annotation object that was added to the map.

Python

Arguments

ArgumentTypeDescription
[annotation]Annotation, dictThe annotation to add to the map.

Returns

Returns the Annotation object that was added to the map.

Examples

map.addAnnotation({
  id: "annotation-1",
  kind: "POINT",
  isVisible: true,
  autoSize: true,
  autoSizeY: true,
  anchorPoint: [-69.30788156774667, -7.1582370789647],
  label: "Annotation 1",
  lineColor: "#C32899",
  lineWidth: 5,
  textWidth: 82.1796875,
  textHeight: 29,
  textVerticalAlign: "bottom",
  armLength: 50,
  angle: -45,
})
map.add_annotation(
    AnnotationCreationProps(
        id="ann_1",
        kind="POINT",
        is_visible=True,
        auto_size=True,
        auto_size_y=True,
        anchor_point=(-69.30788156774667, -7.1582370789647),
        label="Annotation 45",
        line_color="#C32899",
        line_width=5,
        text_width=82.1796875,
        text_height=29,
        text_vertical_align="bottom",
        arm_length=50,
        angle=-45,
    )
)

getAnnotations

Gets all annotations on the map.

Python: get_annotations

getAnnotations: () => Annotation[];
 def get_annotations(self) -> List[Annotation]:

Returns

Returns a list of the Annotations on the map.

Examples

map.getAnnotations();
map.get_annotations()

getAnnotationById

Gets an annotation by providing its ID.

Python: get_annotation_by_id

getAnnotationById: (annotationId: string) => Annotation | null;
def get_annotation_by_id(self, annotation_id: str) -> Optional[Annotation]:

Javascript

Arguments

ArgumentTypeDescription
annotationIdstringThe ID of the annotation to retrieve.

Returns

Returns the Annotation object that was added to the map.

Python

Arguments

ArgumentTypeDescription
annotation_idstrThe ID of the annotation to retrieve.

Returns

Returns the Annotation object that was added to the map.

Examples

map.getAnnotationById("annotation-1");
map.get_annotation_by_id("annotation-1")

removeAnnotation

Removes an annotation from the map.

Python: remove_annotation

removeAnnotation: (annotationId: string) => void;
def remove_annotation(self, annotation_id: str) -> None:

Javascript

Arguments

ArgumentTypeDescription
annotationIdstringThe ID of the annotation to remove.

Python

Arguments

ArgumentTypeDescription
annotation_idstrThe ID of the annotation to remove.

Examples

map.removeAnnotation("annotation-1");
map.remove_annotation("annotation-1")

updateAnnotation

Updates an annotation on the map.

updateAnnotation: (
  annotationId: string,
  values: AnnotationUpdateProps
) => Annotation;
def update_annotation(
    self,
    annotation_id: str,
    values: Union[AnnotationUpdateProps, dict],
) -> Optional[Annotation]

Javascript

Arguments

ArgumentTypeDescription
annotationIdstringThe ID of the annotation to remove.
valuesPartial<Annotation>A partial annotation object to pass as an update the specified annotation.

Returns

Returns the Annotation object that was added to the map.

Python

Arguments

ArgumentTypeDescription
annotation_idstrThe ID of the annotation to remove.
valuesAnnotation, dictA partial annotation object, or a dict, to pass as an update the specified annotation.

Returns

Returns the Annotation object that was added to the map.

Examples

map.updateAnnotation("annotation-1", {
  label: "A new label",
  lineColor: "#FF0000",
})
map.update_annotation("annotation-1", AnnotationUpdateProps(
  label="A new label",
  line_color="#FF0000",
))

Dataset Functions


addDataset

Python: add_dataset

Add a local tabular or tiled dataset object to the map.

addDataset(
  dataset: DatasetCreationProps,
  options?: AddDatasetOptions
): Dataset;
def add_dataset(
    self,
    dataset: Union[
        LocalDatasetCreationProps,
        RasterTileDatasetCreationProps,
        VectorTileDatasetCreationProps,
        Dict,
    ],
    *,
    auto_create_layers: bool = True,
    center_map: bool = True,
) -> Optional[Dataset]

Javascript

Arguments

ArgumentTypeDescription
datasetDatasetCreationPropsData used to create a dataset, in CSV, JSON, GeoJSON format (for local datasets), or a UUID string.
optionsAddDatasetOptionsOptions applicable when adding a new dataset.

Returns

Returns the Dataset object that was added to the map.

Python

Positional Arguments

ArgumentTypeDescription
datasetUnion[Dataset, Dict, None]Data used to create a dataset, in CSV, JSON, or GeoJSON format (for local datasets) or a UUID string.

Keyword Arguments

ArgumentTypeDescription
auto_create_layersboolWhether to attempt to create new layers when adding a dataset. Defaults to True.
center_mapboolWhether to center the map on the created dataset. Defaults to True.
idstrUnique identifier of the dataset. If not provided, a random id will be generated.
labelstrDisplayable dataset label.
colorTuple[float, float, float]Color label of the dataset.
metadatadictObject containing tileset metadata (for tiled datasets).

Returns

Returns the Dataset object that was added to the map.

Examples

// Assume dataset is a valid dataset

map.addDataset({
  id: "test-dataset-01",
  label: "Cities",
  color: [245, 166, 35],
  data: datasetData
},
{
  autoCreateLayers: true,
  centerMap: true
}
)
map.add_dataset(
    LocalDatasetCreationProps(
        id="test-data-id",
        data=TIME_DF,
    )
)

addTileDataset

Adds a new remote dataset to the map, fetching dataset information from the appropriate URL.

addTileDataset(
  dataset: TileDatasetCreationProps,
  options?: AddDatasetOptions
): Promise<Dataset>;`
def add_tile_dataset(
    self,
    dataset: Union[
        VectorTileDatasetRemoteCreationProps,
        RasterTileDatasetRemoteCreationProps,
        Dict,
    ],
    *,
    auto_create_layers: bool = True,
    center_map: bool = True,
) -> Optional[Dataset]

Javascript

Arguments

ArgumentTypeDescription
datasetTileDatasetCreationPropsThe dataset to add.
optionsAddDatasetOptionsOptional map settings for the new dataset.

Returns

Returns a promise with the Dataset object that was added to the map.

Python

Positional Arguments

ArgumentTypeDescription
dataset[Union[Dataset, Dict, None]The dataset to add.

Keyword Arguments

ArgumentTypeDescription
auto_create_layersboolWhether to attempt to create new layers when adding a dataset. Defaults to True.
center_mapboolWhether to center the map on the created dataset. Defaults to True.
idstrUnique identifier of the dataset. If not provided, a random id will be generated.
labelstrDisplayable dataset label.
colorTuple[float, float, float]Color label of the dataset.
metadatadictObject containing tileset metadata (for tiled datasets).

Returns

Returns a promise with the Dataset object that was added to the map.

Examples

map.addTileDataset(
  {
    id: 'foo',
    type: 'raster-tile',
    label: 'Dataset',
    color: [0, 92, 255],
    metadata: {
      // NOTE: This must be a live, reachable URL
      metadataUrl: 'https://path.to.metadata.json'
    }
  },
  {
    autoCreateLayers: true,
    centerMap: true
  }
)
map.add_tile_dataset(RasterTileDatasetRemoteCreationProps(
    id="dataset-id",
    label="dataset-label",
    metadata=RasterTileRemoteMetadata(
        metadata_url=Url("http://example.com"),
    )
))

getDatasetById

Retrieves a dataset by its identifier if it exists.

getDatasetById(
  datasetId: string
): Dataset | null;
get_dataset_by_id(
  self,
  dataset_id: str
) -> Optional[Dataset]:

Javascript

Arguments

ArgumentTypeDescription
datasetIdstringThe identifier of the dataset to retrieve.

Returns

Returns a Dataset object associated with the identifier, or null if no matching dataset was retrieved.

Python

Arguments

ArgumentTypeDescription
dataset_idstringThe identifier of the dataset to retrieve.

Returns

Returns a Dataset object associated with the identifier, or null if no matching dataset was retrieved.

Examples

dataset = map.getDatasetById('test-dataset-01');
dataset = map.get_dataset_by_id("test-dataset-01")

getDatasetWithData

Retrieves a dataset record with its data for a given dataset if it exists.

getDatasetWithData(
  datasetId: string
): DatasetWithData | null;`}
get_dataset_with_data(
  self,
  dataset_id: str
) -> Optional[DatasetWithData]

Javascript

Arguments

ArgumentTypeDescription
datasetIdstringThe identifier of the dataset to retrieve.

Returns

Returns a DatasetWithData record along with its data associated with the identifier, or null if no matching dataset was retrieved.

Python

ArgumentTypeDescription
dataset_idstringThe identifier of the dataset to retrieve.

Returns

Returns a DatasetWithData record along with its data associated with the identifier, or null if no matching dataset was retrieved.

Examples

dataset = map.getDatasetWithData('test-dataset-01');
dataset = map.get_dataset_with_data('test-dataset-01')

getDatasets

Python: get_datasets

Gets all the datasets currently available in the map.

getDatasets(): Dataset[];
get_datasets(self) -> List[Dataset]

Returns

Returns an array of Dataset objects associated with the map.

Examples

datasets = map.getDatasets();
datasets = map.get_datasets()

removeDataset

Python: remove_dataset

Removes a specified dataset from the map.

removeDataset(
  datasetId: string
): void;
remove_dataset(
  self,
  dataset_id: str
)-> None

Javascript

Arguments

ArgumentTypeDescription
datasetIdstringThe identifier of the dataset to remove.

Python

ArgumentTypeDescription
dataset_idstringThe identifier of the dataset to remove.

Examples

map.removeDataset('test-dataset-01');
map.remove_dataset('test-dataset-01')

replaceDataset

Python: replace_dataset

Replaces a given dataset with a new one.

replaceDataset(
  thisDatasetId: string,
  withDataset: DatasetCreationProps
  options?: ReplaceDatasetOptions
): Dataset;
def replace_dataset(
    self,
    this_dataset_id: str,
    with_dataset: Union[
        LocalDatasetCreationProps,
        RasterTileDatasetCreationProps,
        VectorTileDatasetCreationProps,
        Dict,
    ],
    *,
    force: bool = False,
    strict: bool = False,
) -> Dataset

Javascript

Arguments

ArgumentTypeDescription
thisDatasetIdstringIdentifier of the dataset to replace.
withDatasetDatasetCreationPropsDataset details to replace the dataset with.
optionsReplaceDatasetOptionsOptions available for dataset replacement.

Returns

Returns the Dataset object that is now in use.

Python

Arguments

ArgumentTypeDescription
this_dataset_idstringIdentifier of the dataset to replace.
with_datasetUnion[Dataset, Dict, None]Dataset details to replace the dataset with.
forceboolWhether to force a dataset replace, even if the compatibility check fails. Default: false.
strictboolWhether to ensure strict equality of types for each field being replaced. Default: false.

Returns

Returns the Dataset object that is now in use.

Examples

// suppose newDataset is a valid Dataset object
map.replaceDataset('old-dataset-01', newDataset);
map.replace_dataset(
    this_dataset_id="dataset-id-to-replace",
    with_dataset=LocalDatasetCreationProps(
        data=my_data,
    ),
    strict=True
)

updateDataset

Python: update_dataset

Updates an existing dataset's settings.

updateDataset(
  datasetId: string,
  values: DatasetUpdateProps
): Dataset;
def update_dataset(
    self,
    dataset_id: str,
    values: Union[DatasetUpdateProps, dict],
) -> Dataset

Javascript

Arguments

ArgumentTypeDescription
datasetIdstringThe identifier of the dataset to update.
valuesDatasetUpdatePropsThe values to update.

Returns

Returns the updated Dataset object.

Python

Positional Arguments

ArgumentTypeDescription
dataset_idstringThe identifier of the dataset to update.
valuesUnion[_DatasetUpdateProps, dict, None]The values to update.

Keyword Arguments

ArgumentTypeDescription
labelstrDisplayable dataset label.
colorRGBColorColor label of the dataset.

Returns

For non-interactive (i.e. pure HTML) maps, nothing is returned.

Returns the updated Dataset object for interactive maps, or None for non-interactive HTML environments.

Examples

map.updateDataset(
  "test-dataset-01",
  {
    label: "Dataset",
    color: [245, 166, 35],
  }
);
map.update_dataset('dataset-id', DatasetUpdateProps(
    label="My new label",
    color=(255,0,0)
))

Filter Functions


addFilter

Python: add_filter

Add a filter to the map.

addFilter(filter: FilterCreationProps): Filter
def add_filter(
    self,
    filter: Union[
      PartialRangeFilter,
      PartialSelectFilter,
      PartialTimeRangeFilter,
      PartialMultiSelectFilter,
      dict
    ],
) -> Optional[Union[RangeFilter, SelectFilter, TimeRangeFilter, MultiSelectFilter]]

Javascript

Arguments

ArgumentTypeDescription
filterFilterCreationPropsThe filter to add.

Returns

Returns the Filter object that was added to the map.

Python

Positional Arguments

ArgumentTypeDescription
filterUnion[FilterCreationProps, dict, None]The filter to add.

Returns

Returns the Filter object that was added to the map.

Examples

map.addFilter({
  "type": "range",
  "sources": [
    {
      "dataId": "test-dataset-filter",
      "fieldName": "Magnitude"
    }
  ],
  "value": [
    4,
    5
  ]
});
map.add_filter(PartialRangeFilter(
    sources=[PartialFilterSource(
        data_id="test-dataset-filter",
        field_name="Magnitude"
    )],
    value=(4,5)
))

addFilterFromConfig

Python: add_filter_from_config

Add a filter to the map based on its JSON config. These methods can use the content of filter JSON editors directly.

addFilterFromConfig(filterConfig: FilterCreationFromConfigProps): Filter
add_filter_from_config(
  self,
  filter_config: Union[Dict, str]
) -> Filter:

Javascript

Arguments

ArgumentTypeDescription
filterConfigFilterCreationFromConfigPropsThe JSON config for the filter to add.

Returns

Returns the Filter object that was added to the map.

Python

Positional Arguments

ArgumentTypeDescription
filter_configUnion[dict, str] (same shape as FilterCreationFromConfigProps)The JSON config for the filter to add.

Returns

Returns the Filter object that was added to the map.

Examples

map.addFilterFromConfig({
  name: ['time'],
  type: 'timeRange',
  dataId: [TIME_DATASET_ID],
  view: 'minified',
  value: [1655250010, 1655250990],
  animationWindow: 'free',
  yAxis: null,
  speed: 1,
  plotType: {
    type: 'histogram',
    interval: '1-minute',
    aggregation: 'SUM',
    defaultTimeFormat: 'L  LT'
  }
});
map.add_filter_from_config("""{
  "id": "test-filter",
  "type": "timeRange",
  "name": ["time"],
  "dataId": ["test-data-id"],
  "view": "minified",
  "value": [1655250010, 1655250990],
  "animationWindow": "free",
  "yAxis": null,
  "speed": 1,
  "plotType": { "type": "histogram" }
}""")

getFilterById

Python: get_filter_by_id

Retrieves a filter by its identifier if it exists.

getFilterById(
  filterId: string
): Filter | null;
get_filter_by_id(
  self,
  filter_id: str
) -> Optional[Filter]`}

Javascript

Arguments

ArgumentTypeDescription
filterIdstringIdentifier of the filter to get.

Returns

Returns a Filter object associated a given identifier, or null if one doesn't exist.

Python

Arguments

ArgumentTypeDescription
filter_idstringIdentifier of the filter to get.

Returns

Returns a Filter object associated a given identifier, or null if one doesn't exist.

Examples

filter = map.getFilterById('test-filter-01');
filter = map.get_filter_by_id('test-filter-01')

getFilters

Python: get_filters

Gets all the filters currently available in the map.

getFilters(): Filter[];
get_filters(self) -> List[Filter]

Returns

Returns an array of Filter objects.

Examples

filters = map.getFilters();
filters = map.get_filters()

removeFilter

Python: remove_filter

Removes a filter from the map.

removeFilter(
  filterId: string
): void;
remove_filter(
  self,
  filter_id: str
) -> None

Javascript

Arguments

ArgumentTypeDescription
filterIdstringThe id of the filter to remove.

Python

Arguments

ArgumentTypeDescription
filterIdstringThe id of the filter to remove.

Examples

map.removeFilter('test-filter-01');
map.remove_filter('test-filter-01')

updateFilter

Python: update_filter

Updates an existing filter with given values.

updateFilter(
  filterId: string,
  values: FilterUpdateProps
): Filter;`
update_filter(
  self,
  filter_id: str,
  values: Union[FilterUpdateProps, dict, None] = None,
) -> Filter

Javascript

Arguments

ArgumentTypeDescription
filterIdstringThe id of the filter to update.
valuesFilterUpdatePropsThe new filter values.

Returns

Returns the updated Filter object.

Python

Arguments

ArgumentTypeDescription
filter_idstringThe id of the filter to update.
valuesUnion[FilterUpdateProps, dict, None]The new filter values.

Returns

Returns the updated Filter object.

Examples

map.addFilter('test-filter-1',{
  "type": "range",
  "sources": [
    {
      "dataId": "test-dataset-filter",
      "fieldName": "Magnitude"
    }
  ],
  "value": [
    5,
    6
  ]
})
def update_filter(
    self,
    filter_id: str,
    values: Union[
        PartialRangeFilter,
        PartialSelectFilter,
        PartialTimeRangeFilter,
        PartialMultiSelectFilter,
        dict,
    ],
) -> Union[RangeFilter, SelectFilter, TimeRangeFilter, MultiSelectFilter]

updateTimeline

Python: update_timeline

Updates a time range filter timeline with given values.

updateTimeline(
  filterId: string,
  values: FilterTimelineUpdateProps
): TimeRangeFilter;
def update_timeline(
    self,
    filter_id: str,
    values: Union[FilterTimelineUpdateProps, dict],
) -> TimeRangeFilter

Javascript

Arguments

ArgumentTypeDescription
filterIdstringThe id of the time range filter to update.
valuesFilterTimelineUpdatePropsThe new layer timeline values.

Returns

Returns the updated TimeRangeFilter object.

Python

Positional Arguments

ArgumentTypeDescription
filter_idstringThe id of the time range filter to update.
values(Union[,FilterTimelineUpdatePropsdict, None]The new layer timeline values.

Keyword Arguments

ArgumentTypeDescription
viewFilterViewCurrent timeline presentation.
time_formatstringTime format that the timeline is using in day.js supported format. Reference: https://day.js.org/docs/en/display/format
timezonesstringTimezone that the timeline is using in tz format. Reference: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
is_animatingboolFlag indicating whether the timeline is animating or not.
animation_speedNumberSpeed at which timeline is animating.

Returns

Returns the updated TimeRangeFilter object.

Examples

map.updateTimeline('test-timeline-1', {
  timeFormat: 'DD/MM/YYYY',
  isAnimating: false
});
map.update_timeline("filter-id", FilterTimelineUpdateProps(
    view="side",
    is_animating=True
))

Layer Functions


addLayer

Python: add_layer

Add a new layer to the map. This function requires at least one valid layer configuration to be supplied.

To learn about configuring a specific layer programmatically, visit Layer Configuration documentation.

📝

Note:

For Typescript, we recommend using addLayerFromConfig().
For Python users, we recommend using add_layer_from_config() and specialized layer classes. See Python best practices.

addLayer(
  layer: LayerCreationProps
): Layer;
def add_layer(self, layer: Union[LayerCreationProps, dict]) -> Optional[Layer]

Javascript

Arguments

ArgumentTypeDescription
layerLayerCreationPropsA set of properties used to create a layer.

Returns

The Layer object that was added to the map.

Python

Arguments

ArgumentTypeDescription
layerUnion[LayerCreationProps, dict, None]A set of properties used to create a layer.

Returns

The Layer object that was added to the map.

Examples

map.addLayer({
  id: 'test-layer-01',
  type: 'point',
  dataId: 'test-dataset-01',
  label: 'New Layer',
  isVisible: true,
  fields: {
    lat: 'latitude',
    lng: 'longitude'
  },
  config: {
    visualChannels: {
      colorField: {
        name: 'cityName',
        type: 'string'
      },
      colorScale: 'ordinal'
    }
  }
});
map.add_layer(
    LayerCreationProps(
        id="test-layer-01",
        type=LayerType.POINT
        data_id="test-dataset-01",
        label="New Layer",
        is_visible=True,
        fields={"lat": "latitude", "lng": "longitude"},
        config={
            "visual_channels": {
                "color_field": {"name": "city_name", "type": "string"},
                "color_scale":"ordinal",
            }
        },
    )
)

addLayerFromConfig

Python: add_layer_from_config

Adds a layer using the specified config. Provides improved typing over addLayer(), and can work with JSON objects from the JSON editor for layers directly.

Use addLayerFromConfig() over addLayer() when working with large, non-trivial layer configurations.

addLayerFromConfig(layerConfig: LayerCreationFromConfigProps): Layer;
add_layer_from_config(
  self, layer_config: FullLayerConfig
) -> Layer:

Javascript

Arguments

ArgumentTypeDescription
layerConfigLayer JSON ConfigurationA layer config.

Returns

The Layer object that was added to the map.

Python

Arguments

ArgumentTypeDescription
layer_configLayer JSON ConfigurationA layer config.

Returns

The Layer object that was added to the map.

Examples

map.addLayerFromConfig({
  type: 'point',
  config: {
    dataId: myDataset.id,
    columnMode: 'points',
    columns: {
      lat: 'lat',
      lng: 'lon'
    },
    visConfig: {},
    color: [0, 255, 0]
  }
});
# create a disctionary or...
map.add_layer_from_config(
  {
    "id": "sample-layer",
    "type": "point",
    "config": {
      "dataId": "sample-data",
      "label": "Sample layer",
      "columnMode": "points",
      "columns": {"lat": "Latitude", "lng": "Longitude"},
      "visConfig": {},
      "color": [0, 255, 0],
      "textLabel": [],
    },
  }
)

# ...paste a JSON string directly from the JSON editor
map.add_layer_from_config("""
{
  "id": "sample-layer-json-str",
  "type": "point",
  "config": {
    "dataId": "sample-data",
    "label": "Sample layer str",
    ...
    ...
    "columnMode": "points",
    "columns": {
    "lat": "Latitude",
    "lng": "Longitude"
    }
  },
  "visualChannels": {
    "colorField": null,
    "colorScale": "quantile",
    "strokeColorField": null,
    "strokeColorScale": "quantile",
    "sizeField": null,
    "sizeScale": "linear"
  }
}
""")

addLayerGroup

Python: add_layer_group

Adds a new layer group to the map.

addLayerGroup(layerGroup: LayerGroup): LayerGroup;
def add_layer_group(
    self, layer_group: Union[LayerGroupCreationProps, dict]
) -> LayerGroup

Returns

Returns the LayerGroup object added to the map.

Examples

map.addLayerGroup({
  id: 'layer-group-1',
  label: 'Layer Group 1',
  isVisible: true,
  layerIds: ['layer1', 'layer2', 'layer3']
});
map.add_layer_group(LayerGroupCreationProps(
    id="layer-group-1",
    label="Layer Group 1",
    is_visible=True,
    layer_ids=["layer1", "layer2", "layer3"]
))

getLayerById

Python: get_layer_by_id

Retrieves a layer by its identifier if it exists.

getLayerById(
  layerId: string
): Layer | null;
def get_layer_by_id(
  self,
  layer_id: str
) -> Optional[Layer]

Javascript

Arguments

ParameterTypeDescription
layerIdstringIdentifier of the layer to get.

Python

Arguments

ParameterTypeDescription
layer_idstringIdentifier of the layer to get.

Returns

Returns the Layer object associated with the identifier, or null if one doesn't exist.

Examples

layer = map.getLayerById('test-layer-01');
layer = map.get_layer_by_id('test-layer-01')

getLayerGroupById

Python: get_layer_group_by_id

Retrieves a layer group by its identifier if it exists.

getLayerGroupById(layerGroupId: string): LayerGroup | null;
get_layer_group_by_id(self, layer_group_id: str) -> Optional[LayerGroup]:

Returns

Returns a LayerGroup associated with the identifer, or null if one doesn't exist.

Examples

layerGroup = map.getLayerGroupById('layer-group-1');
layer_group = map.get_layer_group_by_id("layer-group-1")

getLayerGroups

Python: get_layer_groups

Gets all the layer groups currently available in the map.

getLayerGroups(): LayerGroup[];
get_layer_groups(self) -> List[LayerGroup]

Returns

Returns an array of LayerGroup objects associated with the map.

Examples

layerGroups = map.getLayerGroups();
layer_groups = map.get_layer_groups()

getLayerTimeline

Python: get_layer_timeline

Gets all the layers currently available in the map.

getLayerTimeline(): LayerTimeline | null;
get_layer_timeline(self) -> Optional[LayerTimeline]:

Returns

Returns a LayerTimeLine object associated with the map.

Examples

layerTimeline = map.getLayerTimeline();
layer_timeline = map.get_layer_timeline()

getLayers

Python: get_layers

Gets all the layers currently available in the map.

getLayers(): Layer[];
get_layers(self) -> List[Layer]

Returns

Returns an array of Layer objects associated with the map.

Examples

layers = map.getLayers();
layers = map.get_layers()

getLayerTimeline

Python: get_layer_timeline

Gets all the layers currently available in the map.

getLayerTimeline(): LayerTimeline | null;
get_layer_timeline(self) -> Optional[LayerTimeline]:

Returns

Returns a LayerTimeLine object associated with the map.

Examples

layerTimeline = map.getLayerTimeline();
layer_timeline = map.get_layer_timeline()

removeLayer

Python: remove_layer

Removes a layer from the map.

removeLayer(
  layerId: string
): void;
remove_layer(
  self,
  layer_id: str
) -> None

Javascript

Arguments

ArgumentTypeDescription
layerIdstringThe id of the layer to remove.

Python

Arguments

ArgumentTypeDescription
layer_idstringThe id of the layer to remove.

Examples

map.removeLayer('test-layer-01');
map.remove_layer('test-layer-01')

removeLayerGroup

Python: remove_layer_group

Removes a layer group from the map. This operation does not remove the layers itself; only the layer group.

removeLayerGroup(layerGroupId: string): void;
remove_layer_group(self, layer_group_id: str) -> None:

Examples

map.removeLayerGroup('layer-group-1');
remove_layer_group(self, layer_group_id: str) -> None:

updateLayer

Python: update_layer

Updates an existing layer with given values.

updateLayer(
  layerId: string,
  values: LayerUpdateProps
): Layer;
def update_layer(
    self, layer_id: str, values: Union[LayerUpdateProps, dict]
) -> Layer

Javascript

Arguments

ArgumentTypeDescription
layerIdstringThe id of the layer to update.
valuesLayerUpdatePropsThe values to update.

Returns

Returns the updated Layer object.

Python

Positional Arguments

ArgumentTypeDescription
layer_idstringThe id of the layer to update.
valuesUnion[LayerUpdateProps, dict, None]The values to update.

Keyword Arguments

ArgumentTypeDescription
typeLayerTypeThe type of layer.
data_idstringUnique identifier of the dataset this layer visualizes.
fieldsDict [string, Optional[string]]Dictionary that maps fields that the layer requires for visualization to appropriate dataset fields.
labelstringCanonical label of this layer
is_visibleboolWhether the layer is visible or not.
configLayerConfigLayer configuration specific to its type.

Returns

Returns the updated Layer object.

Examples

map.updateLayer({
  type: 'point',
  dataId: 'test-dataset-01',
  label: 'Updated Layer',
  isVisible: true,
  fields: {
    lat: 'latitude',
    lng: 'longitude',
    alt: 'altitude'
  },
  config: {
    visualChannels: {
      colorField: {
        name: 'cityName',
        type: 'string'
      }
    },
    visConfig: {
      radius: 10,
      fixedRadius: false,
      opacity: 0.8,
      outline: false,
      thickness: 2
    }
  }
});
map.update_layer('layer-id', LayerUpdateProps(
    label="My new label"
))

updateLayerGroup

Python: update_layer_group

Updates an existing layer group with given values.

updateLayerGroup(layerGroupId: string, values: LayerGroupUpdateProps): LayerGroup;
def update_layer_group(
    self,
    layer_group_id: str,
    values: Union[LayerGroupUpdateProps, dict],
) -> LayerGroup

Returns

Returns the updated LayerGroup.

Examples

map.updateLayerGroup(
    "layer-group-1",
    {
      id: "layer-group-1",
      label: "Layer Group 1",
      isVisible: false,
      layerIds: ["layer1", "layer2". "layer3"]
    }
);
map.update_layer_group(LayerGroupUpdateProps(
    "layer-group-1",
    label = "New Layer Group 1",
    layers = ["layer1", "layer2"]
))

updateLayerTimeline

Python: update_layer_timeline

Updates the current layer timeline configuration.

map.updateLayerTimeline({
    currentTime: 1660637600498,
    isAnimating: true,
    isVisible: true,
    animationSpeed: 1,
    timeFormat: "YYYY-MM-DDTHH:mm:ss",
    timezone: "America/Los_Angeles"
  }
);
def update_layer_timeline(
    self, values: Union[LayerTimelineUpdateProps, dict]
) -> LayerTimeline

Javascript

Arguments

ArgumentTypeDescription
valuesLayerTimelineUpdatePropsThe new layer timeline values.

Returns

Returns the updated LayerTimeline object.

Python

Positional Arguments

ArgumentTypeDescription
values(Union[,LayerTimelineUpdatePropsdict, None]The new layer timeline values.

Keyword Arguments

ArgumentTypeDescription
current_timeNumberCurrent time on the timeline in milliseconds
is_animatingboolFlag indicating whether the timeline is animating or not.
is_visibileboolFlag indicating whether the timeline is visible or not
animation_speedNumberSpeed at which timeline is animating.
time_formatstringTime format that the timeline is using in day.js supported format. Reference: https://day.js.org/docs/en/display/format
timezonestringTimezone that the timeline is using in tz format. https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Returns

Returns the updated LayerTimeline object.

Examples

map.updateLayerTimeline({
    currentTime: 1660637600498,
    isAnimating = true,
    isVisible = true,
    animationSpeed = 1,
    timeFormat = "YYYY-MM-DDTHH:mm:ss",
    timezone = "America/Los_Angeles"
  }
);
map.update_layer_timeline(LayerTimelineUpdateProps(
    current_time=1660637600498,
    is_animating=True,
    is_visible=True,
    animation_speed=1,
    time_format="YYYY-MM-DDTHH:mm:ss",
    timezone="America/Los_Angeles"
))

Map Functions


addToDOM

Javascript-exclusive function.

Adds a map into a container element provided as an argument.

Note: This is normally done in the constructor and does not need to be called explicitly.

addToDOM(
  container: HTMLElement,
  style?: CSSProperties
): void;

Javascript

Arguments

ArgumentTypeDescription
containerHTMLElementThe container element to embed the map into.
styleCSSPropertiesAn optional set of CSS properties.

Returns

Returns the container element to embed the map into.

Examples

map.addToDOM(container, foo.style);

addEffect

Python: add_effect

Add a new visual post-processing effect to the map.

addEffect(
  effect: EffectCreationProps
): Effect;
def add_effect(self, effect: Union[EffectCreationProps, dict]) -> Effect

Javascript

Arguments

ArgumentTypeDescription
effectEffectCreationPropsA set of properties used to create an effect.

Returns

Returns the effect that was added.

Python

ArgumentTypeDescription
effectEffectCreationPropsA set of properties used to create an effect.

Returns

Examples

map.addEffect({
  id: "example-effect",
  type: "light-and-shadow",
  parameters: {
    shadowIntensity: 0.5,
    shadowColor: [0, 0, 0],
    sunLightColor: [255, 255, 255],
    sunLightIntensity: 1,
    ambientLightColor: [255, 255, 255],
    ambientLightIntensity: 1,
    timeMode: "current",
  },
});
map.add_effect(
    EffectCreationProps(
        id="effect-id",
        type=EffectType.INK,
        is_enabled=False,
        parameters={"strength": 0.33},
    )
)

createMap

Python: create_map

Creates a new map instance based on given Arguments.

createMap(
  props: MapCreationProps
): Promise<MapApi>
def create_map(
    *,
    api_key: str,
    renderer: Literal["html", "widget", None] = None,
    initial_state: Optional[Dict] = None,
    style: Optional[Dict] = None,
    basemaps: Optional[Dict] = None,
    urls: Optional[Dict] = None,
    iframe: Optional[bool] = None,
    raster: Optional[Dict] = None,
    _internal: Optional[Dict] = None,
) -> Union[HTMLMap, SyncWidgetMap]

Javascript

Arguments

ArgumentTypeDescription
propsMapCreationPropsA set of properties used to create a layer.

Returns

Returns a new map instance that can be interacted with.

Python

Arguments

ArgumentTypeDescription
rendererstringThe rendering method to use for map rendering, either "html" or "widget". Defaults to None, automatically rendering a widget unless a Databricks environment is detected.

Keyword Arguments

Keyword arguments reflect the parameters found in SyncWidgetMap or most of the parameters found in HTMLMap:

ArgumentTypeDescription
styleDictOptional map container CSS style customization. Uses camelCase as this is React standard.
basemapsDictBasemap customization settings.
basemaps["custom_map_styles"]List[MapStyleCreationProps]A set of properties required when specifying a map style.
basemaps["initial_map_styles"]stringA mapbox style ID.
rasterDictCustomization related to raster datasets and tiles. Not available when renderer = "html".
raster.server_urlsList[string]URLs to custom servers to target when serving raster tiles.
raster.stac_search_urlstringURL to pass to the backend for searching a STAC Collection.
urlsDict
Customization of URLs used in the application.
urls.static_asset_url_basestring
Custom URL base for static assets.
urls.application_url_basestring
Custom URL base for workers and other script resources loaded by the SDK.

Note: HTML rendering is provided for those working in a Databricks environment. While using this rendering method, API endpoints will not provide any return values. Using the default "widget" rendering method is strongly suggested.

Returns

Returns a SyncWidgetMap for most notebook environments, or an HTMLMap object for a Databricks environment or when renderer = "html".

Examples

const map = createMap({apiKey: "<api-key>"});
map = create_map(api_key="<api-key>")

getEffectByID

Python: get_effect_by_id

Retrieves a visual effect from the map.

getEffectById(effectId: string): Effect | null;
get_effect_by_id(effect_id: str) -> Optional[Effect]:

Returns

Returns the effect associated with the ID.

Examples

effect = map.getEffectByID();
effect = map.get_effect_by_id()

getEffects

Python: get_effects

Retrieves all visual effects from the map.

getEffects(): Effect[];
get_effects(self) -> List[Effect]:

Returns

Returns an array of effects added to the map.

Examples

effects = map.getEffects();
effects = map.get_effects()

getMapConfig

Python: get_map_config

Gets the configuration representing the current map state.

For more information, see the JSON reference for the map configuration file.

getMapConfig(): unknown;
get_map_config(self) -> dict:

Returns

Returns the map configuration file.

Examples

mapConfig = map.getMapConfig();
map_config = map.get_map_config()

getMapControlVisibility

Python: get_map_control_visibility

Gets the current map control visibility settings.

getMapControlVisibility(): MapControlVisibility;
get_map_control_visibility(self) -> MapControlVisibility

Returns

Returns a MapControlVisibility object containing current map control visibility settings.

Examples

mapVisibilitySettings = map.getMapControlVisibility();
map_visibility_settings = map.get_map_control_visibility()

getMapStyles

Python: get_map_styles

Gets the current map control visibility settings.

getMapStyles(): MapStyle[];
get_map_styles(self) -> List[MapStyle]

Returns

Returns an array of MapStyle objects.

Examples

mapStyles = map.getMapStyles();
map_styles = map.get_map_styles()

getSplitMode

Python: get_split_mode

Gets the current split mode of the map along with its associated layers.

getSplitMode(): SplitModeProps;
get_split_mode(self) -> SplitModeProps

Returns

Returns a SplitModeProps object containing split mode settings for each associated layers.

Examples

splitMode = map.getSplitMode();
split_mode = map.get_split_mode();

getView

Python: get_view

Gets the current view state of the map.

getView(): View;
get_view(self) -> View

Returns

Returns a View object containing view state settings.

Examples

view = map.getView();
view = map.get_view()

getViewLimits

Python: get_view_limits

Gets the current view limits of the map.

getViewLimits(): ViewLimits;
get_view_limits(self) -> ViewLimits

Returns

Returns a ViewLimits object containing the view limits setting of the map.

Examples

viewLimits = map.getViewLimits();
view_limits = map.get_view_limits()

getViewMode

Python: get_view_mode

Gets the current view mode of the map. View mode can be one of "2d", "3d", or "globe".

getViewMode(): ViewMode;
get_view_mode(self) -> ViewMode

Returns

Returns a ViewMode object containing the view mode setting of the map.

Examples

viewMode = map.getViewMode();
view_mode = map.get_view_mode()

remove_event_handlers

Python exclusive function.

Removes the specified event handlers from the map, layers, or filters.

def remove_event_handlers(
    self, event_handlers: Sequence[Union[str, EventType]]
) -> None:

Arguments

ArgumentTypeDescription
event_handlersSequence[string]A list of event handlers to remove. Passed in as a list of strings.

Examples

map.remove_event_handlers(["on_view_update"])

set_event_handlers

Python exclusive function.

Applies the specified event handlers to the map, layers, or filters.

def set_event_handlers(self, event_handlers: Union[dict, EventHandlers]) -> None

Arguments

ArgumentTypeDescription
event_handlersMapEventHandlers, LayerEventHandlers, FilterEventHandlers, dictEvent handlers to set. Can be passed as in through the aforementioned objects, as a dict, or through keyword arguments.

Examples

map.set_event_handlers(EventHandlers(on_view_update=my_handler_func))

setMapConfig

Python: set_map_config

Loads the given configuration into the current map.

setMapConfig(
  config: object,
  options?: SetMapConfigOptions
): void;
set_map_config(
  self,
  config: dict,
  options: Optional[Union[dict, SetMapConfigOptions]] = None
) -> None:

Javascript

Arguments

ArgumentTypeDescription
configobjectConfiguration to load into the map. For details around the format see the map format reference.
optionsSetMapConfigOptionsA set of options for the map configuration.

Python

Arguments

ArgumentTypeDescription
configdictConfiguration to load into the map. For details around the format see the map format reference.
optionsUnion[dict,SetMapConfigOptions]A set of options for the map configuration.

Examples

map.setMapConfig({
  version: "v1",
  config: {
    visState: {
      filters: [],
      layers: [],
      interactionConfig: {
        tooltip: {
          fieldsToShow: {},
          compareMode: false,
          compareType: "absolute",
          enabled: true
        },
        brush: {
          size: 0.5,
          enabled: false
        },
        geocoder: {
          enabled: false
        },
        coordinate: {
          enabled: false
        }
      },
      layerBlending: "normal",
      overlayBlending: "normal",
      splitMaps: [],
      animationConfig: {
        currentTime: null,
        speed: 1
      },
      editor: {
        features: [],
        visible: true
      },
      metrics: [],
      geoKeys: [],
      groupBys: [],
      datasets: {
        fieldDisplayNames: {},
        fieldDisplayFormats: {},
        datasetColors: {}
      },
      joins: [],
      analyses: [],
      charts: []
    },
    mapState: {
      bearing: 0,
      dragRotate: false,
      latitude: 37.75043,
      longitude: -122.34679,
      pitch: 0,
      zoom: 9,
      isSplit: false,
      isViewportSynced: true,
      isZoomLocked: false,
      splitMapViewports: [],
      mapViewMode: "MODE_2D",
      mapSplitMode: "SINGLE_MAP",
      globe: {
        enabled: false,
        config: {
          atmosphere: true,
          azimuth: false,
          azimuthAngle: 45,
          terminator: true,
          terminatorOpacity: 0.35,
          basemap: true,
          labels: false,
          labelsColor: [
            114.75,
            114.75,
            114.75
          ],
          adminLines: true,
          adminLinesColor: [
            40,
            63,
            93
          ],
          water: true,
          waterColor: [
            17,
            35,
            48
          ],
          surface: true,
          surfaceColor: [
            9,
            16,
            29
          ]
        }
      }
    },
    mapStyle: {
      styleType: "dark",
      topLayerGroups: {},
      visibleLayerGroups: {
        label: true,
        road: true,
        border: false,
        building: true,
        water: true,
        land: true,
        3d building: false
      },
      threeDBuildingColor: [
        9.665468314072013,
        17.18305478057247,
        31.1442867897876
      ],
      backgroundColor: [
        255,
        255,
        255
      ],
      mapStyles: {}
    }
  }
map.set_map_config({
  "version": "v1",
  "config": {
    "visState": {
      "filters": [],
      "layers": [],
      "interactionConfig": {
        "tooltip": {
          "fieldsToShow": {},
          "compareMode": False,
          "compareType": "absolute",
          "enabled": True
        },
        "brush": {
          "size": 0.5,
          "enabled": False
        },
        "geocoder": {
          "enabled": False
        },
        "coordinate": {
          "enabled": False
        }
      },
      "layerBlending": "normal",
      "overlayBlending": "normal",
      "splitMaps": [],
      "animationConfig": {
        "currentTime": null,
        "speed": 1
      },
      "editor": {
        "features": [],
        "visible": True
      },
      "metrics": [],
      "geoKeys": [],
      "groupBys": [],
      "datasets": {
        "fieldDisplayNames": {},
        "fieldDisplayFormats": {},
        "datasetColors": {}
      },
      "joins": [],
      "analyses": [],
      "charts": []
    },
    "mapState": {
      "bearing": 0,
      "dragRotate": False,
      "latitude": 37.75043,
      "longitude": -122.34679,
      "pitch": 0,
      "zoom": 9,
      "isSplit": False,
      "isViewportSynced": True,
      "isZoomLocked": False,
      "splitMapViewports": [],
      "mapViewMode": "MODE_2D",
      "mapSplitMode": "SINGLE_MAP",
      "globe": {
        "enabled": False,
        "config": {
          "atmosphere": True,
          "azimuth": False,
          "azimuthAngle": 45,
          "terminator": True,
          "terminatorOpacity": 0.35,
          "basemap": True,
          "labels": False,
          "labelsColor": [
            114.75,
            114.75,
            114.75
          ],
          "adminLines": True,
          "adminLinesColor": [
            40,
            63,
            93
          ],
          "water": True,
          "waterColor": [
            17,
            35,
            48
          ],
          "surface": True,
          "surfaceColor": [
            9,
            16,
            29
          ]
        }
      }
    },
    "mapStyle": {
      "styleType": "dark",
      "topLayerGroups": {},
      "visibleLayerGroups": {
        "label": True,
        "road": True,
        "border": False,
        "building": True,
        "water": True,
        "land": True,
        "3d building": False
      },
      "threeDBuildingColor": [
        9.665468314072013,
        17.18305478057247,
        31.1442867897876
      ],
      "backgroundColor": [
        255,
        255,
        255
      ],
      "mapStyles": {}
    }
  }

setMapControlVisibility

Python: set_map_control_visibility

setMapControlVisibility(
  visibility: Partial<MapControlVisibility>
): MapControlVisibility;
def set_map_control_visibility(
    self,
    visibility: Union[PartialMapControlVisibility, Dict[str, bool]],
) -> Optional[MapControlVisibility]

Javascript

Arguments

ArgumentTypeDescription
visibilityMapControlVisibilityThe new map control visibility settings.

Returns

Returns a MapControlVisibility object containing the updated map control visibility settings.

Python

Positional Arguments

ArgumentTypeDescription
visibilityUnion[MapControlVisibility, dict, None]MapControlVisibility model instance or a dict with the same attributes, all optional.

Keyword Arguments

ArgumentTypeDescription
legendboolWhether the legend is visible.
toggle_3dboolWhether the 3D toggle is visible.
split_mapboolWhether the split map button is visible.
map_drawboolWhether the map draw button is visible.

Returns

Returns a MapControlVisibility object containing the updated map control visibility settings.

Examples

map.setMapControlVisibility({
  legend: false,
  map-draw: false,
  split-map: true,
  toggle-3d: false,
  chart: false
});
map.set_map_control_visibility(
    PartialMapControlVisibility(
      legend=False,
      toggle_3d=True
    )
)

setSplitMode

Python: set_split_mode

Sets the split mode of the map.

map.setSplitMode('swipe', {
  layers: [['left_layer'], ['right_layer']],
  isViewSynced: true,
  isZoomSynced: true
});
def set_split_mode(
    self,
    split_mode: Literal["single", "dual", "swipe"],
    options: Union[PartialSplitModeContext, dict],
) -> Optional[SplitModeDetails]

Javascript

Arguments

ArgumentTypeDescription
splitModeSplitModeSplit map mode with associated layers.
optionsPartial<SplitModeContext>A set of options to use when setting the split mode.

Returns

Returns a SplitModeDetails object containing the updated split mode of the map along with its associated layers.

Python

Positional Arguments

ArgumentTypeDescription
split_mode_props SplitModePropsSplit map mode with associated layers.

Keyword Arguments

ArgumentTypeDescription
modeSplitModeSplit map mode with associated layers.
layersSplitLayersArrays with layer Ids per each post-split map section.

Returns

Returns a SplitModeProps object containing the updated split mode of the map along with its associated layers, or null for

Examples

map.setSplitMode('swipe', {
  layers: ['left_layer', 'right_layer'],
  isViewSynced: true,
  isZoomSynced: true
});
map.set_split_mode(split_mode='dual', options=PartialSplitModeContext(
    is_view_synced=True,
    is_zoom_synced=False,
))

setTheme

Python: set_theme

Sets the UI theme of the map.

setTheme(
  theme: ThemeUpdateProps
): void;
def set_theme(
    self,
    preset: Optional[Literal["light", "dark"]] = None,
    background_color: Optional[str] = None,
) -> None

Javascript

Arguments

ArgumentTypeDescription
themeThemeUpdatePropsNew UI theme settings.

Python

Arguments

ArgumentTypeDescription
presetThemePresetsA preset theme, either "light" or "dark"
background_colorstringOptional. A background color.

Examples

map.setTheme({
  preset: 'light',
  options: {
    backgroundColor: 'lightseagreen'
  }
});
map.set_theme(
  preset="dark",
  background_color="lightseagreen"
)

setView

Python: set_view

Sets the view state of the map.

setView(
  view: Partial<View>
): View;
def set_view(
    self, view: Union[PartialView, Dict[str, Number]], *, index: int = 0
) -> Optional[View]

Javascript

Arguments

ArgumentTypeDescription
viewViewType encapsulating view properties.

Returns

Returns the updated View state object.

Python

Positional Arguments

ArgumentTypeDescription
viewUnion[View, dict, None]View model instance or a dict with the same attributes

Keyword Arguments

ArgumentTypeDescription
latitudenumberLongitude of the view center [-180, 180].
longitudenumberLatitude of the view center [-90, 90].
zoomnumberView zoom level [0-22].
pitchnumberView pitch value [0-90].
bearingnumberView bearing [0-360].

Returns

Returns the updated View state object.

Examples

map.setView({
  longitude: -118.8189,
  latitude: 34.01207,
  zoom: 10,
  pitch: 0,
  bearing: 0
});
map.set_view(PartialView(
    longitude = -118.8189,
    latitude = 34.01207,
    zoom = 10,
    pitch = 0,
    bearing = 0
))

setViewLimits

Python: set_view_limits

Sets the view state of the map.

setViewLimits(
  viewLimits: Partial<ViewLimits>,
  options?: SetViewLimitsOptions
): ViewLimits;
def set_view_limits(
    self,
    view_limits: Union[PartialViewLimits, dict],
    *,
    index: int = 0,
) -> Optional[ViewLimits]

Javascript

Arguments

ArgumentTypeDescription
viewLimitsPartial<ViewLimits>Type encapsulating view properties.
optionsSetViewLimitsOptionsA set of options to use when setting the view limit.

Returns

Returns the updated ViewLimits state object.

Python

Positional Arguments

ArgumentTypeDescription
view_limitsUnion[ViewLimits, dict, None]ViewLimits model instance or a dict with the same attributes, all optional.

Keyword Arguments

ArgumentTypeDescription
min_zoomNumberMinimum zoom of the map [0-22].
max_zoomNumberMaximum zoom of the map [0-22].
max_boundsBounds, dicta Bounds object or a dict with the keys (min_longitude, max_longitude, min_latitude, max_latitude).

Returns

Returns the updated ViewLimits state object.

Examples

map.setViewLimits({
  minZoom: 0,
  maxZoom: 22,
  maxBounds: {
    minLongitude: -122.4845632122524,
    maxLongitude: -121.7461580455235,
    minLatitude: 37.49028773126059,
    maxLatitude: 37.94131376494916
  }
});
map.set_view_limits(PartialViewLimits(
    min_zoom=0,
    max_zoom=22,
    max_bounds=Bounds(
        min_longitude=-122.4845632122524,
        max_longitude=-121.7461580455235,
        min_latitude=37.49028773126059,
        max_latitude=37.94131376494916
    )
))

setViewMode

Python: set_view_mode

Sets the view mode of the map to either "2d", "3d", or "globe".

setViewMode(
  viewMode: ViewMode
): ViewMode;
def set_view_mode(
    self,
    view_mode: Literal["2d", "3d", "globe"],
) -> Optional[Literal["2d", "3d", "globe"]]

Javascript

Arguments

ArgumentTypeDescription
viewModeviewModeThe view mode for the map, either "2d", "3d", or "globe".

Returns

Returns the updated ViewMode state object.

Python

Arguments

ArgumentTypeDescription
viewModeviewModeThe view mode for the map, either "2d", "3d", or "globe".

Returns

Returns the updated ViewMode state object.

Examples

map.setViewMode("3d");
map.set_view_mode("3d")

setViewFromConfig

Python: set_view_from_config

Sets the entire view from the view JSON configuration.

setViewFromConfig(
  viewConfig: ViewConfig
): void;
set_view_from_config(
    self,
    view_config: Union[Dict, str]
) -> None:

Javascript

Arguments

ArgumentTypeDescription
viewConfigViewConfigJSON config of a view.

Python

Arguments

ArgumentTypeDescription
view_configUnion[Dict, str] (corresponds to ViewConfig)JSON config of a view.

Examples

map.setViewFromConfig({
  isSplit: false,
  mapSplitMode: "SINGLE_MAP",
  mapViewMode: "MODE_2D",
  latitude: 37.3510537,
  longitude: -14.755157,
  zoom: 2.3,
  pitch: 0,
  bearing: 0
});
map.set_view_from_config("""{
  "isSplit": false,
  "mapSplitMode": "SINGLE_MAP",
  "mapViewMode": "MODE_2D",
  "latitude": 37.3510537,
  "longitude": -14.755157,
  "zoom": 2.3,
  "pitch": 0,
  "bearing": 0
}""")

setAnimationFromConfig

Python: set_animation_from_config

Sets the animation properties from the animation JSON configuration.

This function can configure animation to either of types of animation (layer and timeline type of animation).

setAnimationFromConfig(
  config: AnimationConfig
): void;
set_animation_from_config(
    self,
    animation_config: Union[dict, str, Animation, FilterAnimation]
) -> None:

Javascript

Arguments

ArgumentTypeDescription
configAnimationConfigJSON config for animation.

Python

Arguments

ArgumentTypeDescription
animation_configUnion[dict, str, Animation, FilterAnimation] JSON config for animation.

Examples

map.setAnimationFromConfig({
  currentTime: 123,
  speed: 1.1,
  domain: [100, 200],
  timeFormat: 'L LTS'
});
map.set_animation_from_config("""{
    "currentTime": 1655251000,
    "domain": [1655250000, 1655251000],
    "speed": 1.2,
    "timeFormat": "L LTS"
}""")

updateEffect

Python: update_effect

Updates a visual post-processing effect to the map.

updateEffect(
  effectId: string,
  values: EffectUpdateProps
): Effect;
def update_effect(
    self,
    effect_id: str,
    values: Union[EffectUpdateProps, dict],
) -> Optional[Effect]

Javascript

Arguments

ArgumentTypeDescription
effectIdstringThe ID for the effect to update.
valuesEffectUpdatePropsA set of properties used to update an effect.

Returns

Returns the updated effect.

Python

ArgumentTypeDescription
effect_idstringThe ID for the effect to update.
valuesEffectUpdatePropsA set of properties used to update an effect.

Returns

Returns the updated effect.

Examples

map.updateEffect({
  id: "effect-id",
  isEnabled: false,
  parameters: {
    shadowIntensity: 0.75,
    shadowColor: [25, 50, 75]
  },
});
map.update_effect(
    "effect-id",
    values=EffectUpdateProps(
        is_enabled=True,
        parameters={"strength": 0.5}
    ),
)