Map Functions

Using the Map SDK, you can configure the visualization configuration of maps, then embed them into a webpage or notebook.

For a full description of a function and its parameters, please follow the link to the full Map SDK reference.


Create Map

Creates a new map. If creating a map from scratch, you likely do not need to pass any parameters.

However, you can pass a MapCreationProps object (or keyword arguments in Python), allowing you to customize the style, event handlers, basemaps, raster support, and various UI configuration settings. Many of these advanced options are only available for pro accounts.

const map = createMap();
map = create_map()

Arguments

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

ArgumentTypeDescription
mapMapCreationPropsAn object containing map creation parameters.
map.containerHTMLElementDOM element to embed map into.
map.styleCSSPropertiesMap container CSS style customization.
map.eventHandlersMapEventHandlersEvent handlers to attach to the map.
map.showPlaceholderboolVisibility of loading screen placeholder. Default: true
map.basemapsobjectBasemap customization settings.
map.basemaps.customMapStylesMapStyleCreationProps[]Custom map styles to make available for usage.
map.basemaps.mapboxAccessTokenstringMapbox token to be used when loading the provided custom map styles.
map.basemaps.initialMapStyleIdstringIdentifier for the map style to be used initially.
map.transformRequestfunctionFunction to transform basemap resource requests.
map.rasterobject
Customization related to raster datasets and tiles.
map.raster.serverUrlsstring[]
URLs to custom servers to target when serving raster tiles.
map.raster.stacSearchUrlsstring
URL to pass to the backend for searching a STAC Collection.
map.uiConfigobject
UI configuration object.
map.uiConfig.mapNamestring
Name of the map to show in the title. Default = Studio
map.uiConfig.sidePanelobject
A UI component displaying options for data, layer, and map manipulation.
map.uiConfig.sidePanel.viewstring
View state of the side panel. Options include 'hidden','collapsed', or 'visible'.
map.uiConfig.sidePanel.isAddLayerVisiblebool
When enabled, display the "Add Layer" button.
map.uiConfig.sidePanel.addDataButtonobject
Custom settings for the Add Data button.
map.uiConfig.sidePanel.addDatabutton.onClick
Custom event handler for the Add Data button.
map.uiConfig.sideNavobject
A UI element containing company logo and relevant links.
map.uiConfig.sideNav.isVisiblebool
When enabled, display the sidenav sidePanel.
map.urls.staticAssetUrlBasestring
Custom URL base for static assets.
map.urls.applicationUrlBasestring
Custom URL base for workers and other script resources loaded by the SDK.

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


Get Map Configuration

Gets the configuration representing the current map state.

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

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

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


Get Map Control Visibility

Gets the current map control visibility settings. This object contains flags that control the visibility of the legend, toggle_3d, split_map, and map_draw buttons.

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

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


Get Split Mode

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

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

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


Get View

Gets the current view state of the map. The view state object contains the viewport's latitude, longitude, zoom, pitch, and bearing.

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

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


Get View Limits

Gets the current view limits of the map. This includes the minZoom, maxZoom, and maxBounds, all of which limit the user's viewport.

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

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


Remove Event Handlers

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

Note: This function only exists for Python. While using Javascript, event handlers can be accessed, added, and modified through the map object.

map.remove_event_handlers(["on_view_update"])

Arguments

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

For more information, see remove_event_handlers() in the full API reference.


Set Event Handlers

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

Note: This function only exists for Python. While using Javascript, event handlers can be accessed, added, and modified through the map object.

map.set_event_handlers(on_view_update = do_something)

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.

For more information, see set_event_handlers() in the full API reference.


Set Map Control Visibility

Sets the visibility of map controls, including the legend, toggle-3d, split-map, and map-draw buttons.

map.setMapControlVisibility({
  legend: true,
  toggle-3d: true,
  split-map: true,
  map-draw: true,
});
map.set_map_control_visibility({
  "legend": True,
  "toggle-3d": True,
  "split-map": True,
  "map-draw": True,
})

Arguments

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

ArgumentTypeDescription
mapControlsobjectObject containing map control visibility settings.
mapControls.legendboolWhether the legend is visible.
mapControls.toggle-3dboolWhether the 3D toggle is visible.
mapControls.split-mapboolWhether the split map button is visible.
mapControls.map-drawboolWhether the map draw button is visible.

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


Set Split Mode

Set the split mode of the map. Takes SplitMode and an options object.

map.setSplitMode('swipe', {
  layers: ['left_layer', 'right_layer'],
  isViewSynced: true,
  isZoomSynced: true
});
map.set_split_mode(
  mode = "swipe",
  layers: ["left_layer", "right_layer"]
)

Arguments

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

ArgumentTypeDescription
splitModestringSupported split map modes. Either 'single', 'dual', or 'swipe'.
splitModeOptionsobjectAn object containing split mode map options.
splitModeOptions.layersstring[][]Optional array of layerIds to show on either side of the split. Only applicable for dual and swipe split modes.
splitModeOptions.isViewSyncedboolBoolean indicating whether views are synced. Only applicable to dual split mode.
splitModeOptions.isZoomSyncedboolBoolean indicating whether zoom is synced between views. Only applicable to dual split mode.

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


Set Theme

Sets the UI theme of the map. A theme contains a preset (either light or dark), as well as an optional background_color.

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

Arguments

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

ArgumentTypeDescription
themeobjectAn object containing UI theme preset options.
theme.presetstringUI theme preset name.
theme.optionsobjectOptional UI theme customization options.
theme.options.backgroundColorstringBackground color of UI elements in a CSS color string.

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


Set View

Sets the view state of the map. The view state object should contain the viewport's latitude, longitude, zoom, pitch, and bearing.

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

Arguments

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

ArgumentTypeDescription
viewobjectAn object containing view options.
view.longitudenumberLongitude of the view center [-180, 180].
view.latitudenumberLatitude of the view center [-90, 90].
view.zoomnumberView zoom level [0-22].
view.pitchnumberView pitch value [0-90].
view.bearingnumberView bearing.

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


Set View Limits

Set the view limits of the map. This includes the minZoom, maxZoom, and maxBounds, all of which limit the user's viewport.

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

Arguments

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

ArgumentTypeDescription
viewLimitsobjectAn object containing view limit options.
viewLimit.sminZoomnumberMinimum allowed zoom level.
viewLimit.maxZoomnumberMaximum allowed zoom level.
viewLimit.maxBoundsobjectObject containing optional maximum allowed bounds.
viewLimit.maxBound.minLongitudenumberMinimum (left) longitude value.
viewLimit.maxBound.maxLongitudenumberMaximum (right) longitude value.
viewLimit.maxBound.minLatitudenumberMinimum (bottom) latitude value.
viewLimit.maxBound.maxLatitudenumberMaximum (top) latitude value.

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