Layer Functions

The Map SDK provides a variety of layer functions, allowing you to add, remove, and configure the visibility of layers on your map.


Add Layer

Add a new layer to the map.

This function requires the user to supply at least one valid layer configuration object.

🚧

Note: Any specified dataset must be added to the map in advance.

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(
  {
    "id": "test-layer-01",
    "type": "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"
      }
    }
    }
)

Arguments

Note: Python Arguments require Python syntax and camel_case parameter names.

ArgumentTypeDescription
layerobjectAn object containing layer details.
layer.idstringUnique identifier of the layer.
layer.typestringType of the layer. See all available layers in the LayerType documentation.
layer.dataIdstringUnique identifier of the dataset this layer visualizes.
layer.fieldsRecord<string, string>Dictionary that maps fields that the layer requires for visualization to appropriate dataset fields.
layer.labelstringCanonic label of this layer.
layer.isVisiblebooleanFlag indicating whether layer is visible or not.
layer.configLayerConfigJSON layer configuration.

For more information, including full Python documentation, see addLayer() in the full API reference.


Add Layer Group

Add a new layer group to the map.

Layer groups do not impact the visualization itself, and instead serve as folders that organize layers within the sidebar. Assign layerIds to be a member of the layer group.

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

Arguments

Note: Python Arguments require Python syntax and camel_case parameter names.

ArgumentTypeDescription
layerGroupobjectAn object containing layer group options.
layerGroup.idstringUnique identifier of the layer group.
layerGroup.labelstringCanonical label of this group.
layerGroup.isVisiblebooleanFlag indicating whether layer group is visible or not.
layerGroup.layerIdsstring[]Layers referenced by layerId that are part of this group, sorted in the order in which they are shown.

For more information, including full Python documentation, see addLayerGroup() in the full API reference.


Get Layer by ID

Retrieve a Layer object by passing a valid layer layerId.

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

Arguments

Note: Python Arguments require Python syntax and camel_case parameter names.

ArgumentTypeDescription
layerIdstringUnique identifier of the layer.

For more information, including full Python documentation, see getLayerById() in the full API reference.


Get Layer Group by ID

Retrieve a LayerGroup object by passing a valid layer group LayerGroupId.

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

Arguments

Note: Python Arguments require Python syntax and camel_case parameter names.

ArgumentTypeDescription
layerGroupIdstringUnique identifier of the layer group.

For more information, including full Python documentation, see getLayerGroupById() in the full API reference.


Get Layer Groups

Retrieve all LayerGroups present on the map.

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

For more information, including full Python documentation, see getLayerGroups() in the full API reference.


Get Layers

Gets all the Layers currently available on the map.

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

For more information, including full Python documentation, see getLayers() in the full API reference.


Get Layer Timeline

Retrieve the LayerTimeline object associated with the map.

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

For more information, including full Python documentation, see getLayerTimeline() in the full API reference.


Remove Layer

Remove a layer from the map by passing a valid layerId.

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

Arguments

Note: Python Arguments require Python syntax and camel_case parameter names.

ArgumentTypeDescription
layerIdstringUnique identifier of the layer to remove.

For more information, including full Python documentation, see removeLayer() in the full API reference.


Remove Layer Group

Remove a layer group by passing a valid layerGroupId.

map.removeLayerGroup('layer-group-1');
map.remove_layer_group("layer-group-1")

Arguments

Note: Python Arguments require Python syntax and camel_case parameter names.

ArgumentTypeDescription
layerGroupIdstringUnique identifier of the layer group to remove.

For more information, including full Python documentation, see removeLayerGroup() in the full API reference.


Update Layer

Update an existing layer with the given values. Pass the layerId to target the layer you wish to update, then provide new Layer parameters in a values object.

map.updateLayer('test-layer-01', {
  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(
  "test-layer-01",
  {
  "type": "point",
  "data_id": "test-dataset-01",
  "label": "Updated Layer",
  "is_visible": True,
  "fields": {
    "lat": "latitude",
    "lng": "longitude",
    "alt": "altitude"
  },
  "config": {
    "visual_channels": {
      "color_field": {
        "name": "city_name",
        "type": "string"
      },
    },
    "vis_config": {
      "radius": 10,
      "fixed_radius": False,
      "opacity": 0.8,
      "outline": False,
      "thickness": 2
    }
  }
})

Arguments

Note: Python Arguments require Python syntax and camel_case parameter names.

ArgumentTypeDescription
layerIdstringUnique identifier of the layer to update.
layerobjectAn object containing layer details.
layer.typestringType of the layer. See all available layers in the LayerType documentation.
layer.dataIdstringUnique identifier of the dataset this layer visualizes.
layer.fieldsRecord<string, string>Dictionary that maps fields that the layer requires for visualization to appropriate dataset fields.
layer.labelstringCanonic label of this layer.
layer.isVisiblebooleanFlag indicating whether layer is visible or not.
layer.configLayerConfigJSON layer configuration.

For more information, including full Python documentation, see updateLayer() in the full API reference.


Update Layer Group

Update an existing layer group with the given values. Pass the layerGroupId to target the layer you wish to update, then provide new LayerGroup parameters in a values object.

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

Arguments

Note: Python Arguments require Python syntax and camel_case parameter names.

ArgumentTypeDescription
layerGroupIdstringUnique identifier of the layer group.
layerGroupobjectAn object containing layer group options.
layerGroup.labelstringCanonical label of this group.
layerGroup.isVisiblebooleanFlag indicating whether layer group is visible or not.
layerGroup.layerIdsstring[]Layers referenced by layerId that are part of this group, sorted in the order in which they are shown.

For more information, including full Python documentation, see updateLayerGroup() in the full API reference.


Update Layer Timeline

Updates the current layer timeline configuration. Pass LayerTimeline parameters in a values object.

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

Arguments

Note: Python Arguments require Python syntax and camel_case parameter names.

ArgumentTypeDescription
valuesobjectAn object containing layer timeline settings to pass as an update.
values.currentTimenumberCurrent time on the timeline in milliseconds.
values.domaintimeRangeRange of time that the timeline shows.
values.isAnimatingbooleanFlag indicating whether the timeline is animating or not.
values.isVisiblebooleanFlag indicating whether the timeline is visible or not.
values.animationSpeednumberSpeed at which timeline is animating.
values.timeFormatstringTime format that the timeline is using in day.js supported format.
values.timezonestringTimezone that the timeline is using in tz format.
values.timeStepsnumber[]Step duration for all the animation keyframes in milliseconds.

For more information, including full Python documentation, see updateLayerTimeline() in the full API reference.