Skip to main content

The Mapbox Map component for Retool Apps

A content area to embed a map with custom locations.

An embedded map using MapBox to display latitude and longitude coordinates as points of interest. It supports custom markers using Emoji and symbols, default coordinates and zoom level, and GeoJSON to render custom shapes for highlighting locations.

Mapbox Map can trigger queries when panning or zooming the map, and on hover start or end for points.

Refer to the Mapbox guide for more information about using this component.

Properties

All properties for this object with supported data types or values. You can write JavaScript almost anywhere in Retool to manipulate or read property values.

events

A list of configured event handlers that trigger actions or queries.

Type array
Array values object
Configurability Inspector > Interaction > Event handlers
Defaultnull
Array Object Properties

event

The event that triggers the action. Refer to the events section for details of available events for this object.

Type string
Configurability Inspector > Interaction > Event handlers > Event
Defaultnull

method

The JavaScript method to perform when type is datasource, widget, state, or localStorage.

Type string
Configurability Inspector > Interaction > Event handlers > Edit event handler > Run script actions
Defaultnull

type

The type of action to perform.

Type string
Configurability Inspector > Interaction > Event handlers > Edit event handler > Action
Allowed Values
ValueDescription
datasource

Control query.

widget

Control component.

script

Run script.

state

Set variable.

localStorage

Set localStorage.

util

Perform utility action (e.g., Open URL or Confetti).

Defaultnull


fitBoundsToGeoJson

Whether to fit the map bounds to the GeoJSON data.

Type boolean
Configurability Inspector
Defaultnull

geoJson

GeoJSON objects to display on the map, such as polygons.

Type object
Configurability Inspector
Defaultnull

geoJsonLayerStyle

Mapbox GeoJSON layer styles that override any other applied styling.

Type object
Configurability Inspector
Defaultnull

hidden

Whether this object is hidden from view.

Type boolean
Format True/False
Configurability Inspector > Appearance > Hidden
Defaultfalse
Examples
true

hoveredOverPoint

The point on which the cursor hovers.

Type object
Configurability Read-only
Defaultnull

id

The unique identifier (name).

Type string
Format Plain Text
Configurability Inspector
DefaultmapboxMap1
Examples
query1
button1

isHiddenOnDesktop

Whether to show or hide this object in the desktop layout.

Type boolean
Format True/False
Configurability Inspector > Appearance > Advanced > Show on desktop
Defaultfalse
Examples
true

isHiddenOnMobile

Whether to show or hide this object in the mobile layout.

Type boolean
Format True/False
Configurability Inspector > Appearance > Advanced > Show on mobile
Defaulttrue
Examples
true

latitude

The latitudinal position.

Type number
Configurability Inspector
Defaultnull

latitudeColumnName

The key for latitude values if different from latitude.

Type string
Configurability Inspector
Defaultnull

longitude

The longitudinal position.

Type number
Configurability Inspector
Defaultnull

longitudeColumnName

The key for longitude values if different from longitude.

Type string
Configurability Inspector
Defaultnull

maintainSpaceWhenHidden

Whether to take up space on the canvas if hidden is true.

Type boolean
Format True/False
Configurability Inspector > Appearance > Advanced > Maintain space when hidden
Defaultfalse
Examples
true

margin

The amount of margin to render outside.

Type string
Format Plain Text
Configurability Inspector > Spacing > Margin
Allowed Values
ValueUI OptionDescription
4px 8pxNormal

Normal margin.

0None

No margin.

Default4px 8px
Examples
4px 8px

onPointHoveredOver

The event handler to run when a point is hovered over.

Type string
Configurability Read-only
Defaultnull

onPointHoveredOverEnd

The event handler to run when a point is no longer hovered over.

Type string
Configurability Read-only
Defaultnull

onPointSelected

The event handler to run when a point is selected.

Type string
Configurability Read-only
Defaultnull

onViewportChange

The event handler to run when the viewport changes.

Type string
Configurability Read-only
Defaultnull

points

A list of map points to display.

Type array
Array values object
Configurability Inspector
Defaultnull
Array Object Properties

color

The color with which to render.

Type string
Configurability Read-only
Defaultnull

id

The unique identifier for the point.

Type string
Configurability Read-only
Defaultnull

latitude

The latitudinal position.

Type number
Configurability Read-only
Defaultnull

longitude

The longitudinal position.

Type number
Configurability Read-only
Defaultnull


pointValue

The point value to display.

Type object
Configurability Read-only
Defaultnull

selectedPoint

The selected point.

Type object
Configurability Read-only
Defaultnull

showCurrentLngLat

Whether to show the latitude and longitude coordinates.

Type boolean
Configurability Inspector
Defaultnull

showInEditor

Whether the component remains visible in the editor if hidden is true.

Type boolean
Format True/False
Configurability Inspector > Appearance > Advanced > Always show in edit mode
Defaultfalse
Examples
true

style

Custom style options.

Type object
Configurability Inspector > Appearance > style
Defaultnull

visiblePoints

A list of map points visible.

Type array
Array values object
Configurability Read-only
Defaultnull

zoom

The zoom level, from 0 to 16.

Type number
Configurability Inspector
Defaultnull

Methods

JavaScript API methods for this object. You can write JavaScript almost anywhere in Retool and use methods to manipulate data and property values.

mapboxMap.scrollIntoView()

Scrolls the canvas or parent container so that the selected component appears in the visible area.

Definition
mapboxMap.scrollIntoView(options)
Parameters

options

The scroll options.

Type object
Object Properties

behavior

The scroll behavior.

Type string
Allowed Values
ValueDescription
auto

Scroll immediately to the specified position.

smooth

Scroll gradually to the specified position.


block

The scroll position relative to the component.

Type string
Allowed Values
ValueDescription
nearest

Scrolls only the minimum amount required for the component to appear in the visible area. Scrolling does not occur if the component is already in view.

start

Scrolls to position the component at the top of the visible area.

center

Scrolls to position the component in the middle of the visible area.

end

Scrolls to position the component at the bottom of the visible area.



Examples

Scroll the minimum amount to immediately bring mapboxMap into view.

mapboxMap.scrollIntoView({behavior: 'auto', block: 'nearest'});

mapboxMap.selectPoint()

Select a point on the map.

Definition
mapboxMap.selectPoint(latitude, longitude)
Parameters

latitude

The latitudinal position.

Type number

longitude

The longitudinal position.

Type number


mapboxMap.setMapCenter()

Set the center of the map.

Definition
mapboxMap.setMapCenter(options)
Parameters

options

The latitude and longitude of the center of the map.

Type object
Object Properties

latitude

The latitudinal position.

Type number

longitude

The longitudinal position.

Type number



Events

Events triggered by user interactions. You can configure event handlers in the IDE to trigger queries or other actions in response to events.

EventDescription
On Point Hovered OverA point of interest is hovered over.
On Point Hovered Over EndA point of interest is no longer hovered over.
On Point SelectedA point of interest is selected.
On Viewport ChangeThe viewport is changed.