Skip to main content

Map

The Map component enables users to display a map on the app. It can be used to display or choose a single location or multiple locations on the map. The Map component can be used to display the location of a business, a store, or a restaurant. It can also be used to display the location of a user on the map. It allows users to interact with the map interface and pick specific points of interest.

Using Self-hosted

If you are utilizing the self-hosted version of ToolJet, it is necessary to configure the Google Maps API key as an environment variable. Please refer to the environment variable setup documentation.

ToolJet - Component Reference - Map

Properties​

Properties
Description
Expected Value
Initial locationdefault location when the app is loaded initially.An object containing the latitude and longitude as key value pairs. ex: {{ {"lat": 40.7128, "lng": -73.935242} }}.
Default markersThe markers shown on the map when the app loads.An array of objects with lat, lng and an optional label. ex: {{ [{"lat": 40.7128, "lng": -73.935242, "label": "A"}] }}.
Polygon pointsCreate a polygon on the map using the given coordinates. Needs at least two points.An array of objects containing the coordinates. ex: {{ [{"lat": 40.7128, "lng": -73.935242}, {"lat": 40.7128, "lng": -73.835242}, {"lat": 40.7528, "lng": -73.885242}] }}.
Add new markersOn clicking the map, a new marker will be added to the map.By default, it's set to On. Toggle off to disable adding new markers on the map. Click fx to set {{true}} or {{false}} programmatically.
Search for placesEnable to show the search box on the map.By default, it's set to On. Toggle off to disable the search box on the map. Click fx to set {{true}} or {{false}} programmatically.

Events​

Event Name
Description
On bounds changeTriggers after the user finishes dragging the map, or selects a place from the search box. It doesn't trigger on zoom or setLocation.
On create markerTriggers when a new marker is added to the map.
On marker clickTriggers when the user clicks on any of the markers on the map.
On polygon clickTriggers when the user clicks on the polygon on the map.
info

For detailed information about all the available Actions, please refer to the Action Reference documentation.

Component Specific Actions (CSA)​

Following actions of Map component can be controlled using the component specific actions(CSA):

Actions
Description
How To Access
setLocationCenters the map on the given latitude and longitude. It doesn't add or move a marker, and doesn't update the center or bounds variables.Employ a RunJS query to execute component-specific actions such as: components.map1.setLocation(40.7128, -73.935242).

Exposed Variables​

Exposed variables can be used to get data from the component.

Variables
Description
How To Access
centerHolds the latitude, longitude and Google Maps URL of the map's current center.Access the value dynamically using JS: {{components.map1.center}}.
center.latHolds the latitude of the map's current center.Access the value dynamically using JS: {{components.map1.center.lat}}.
center.lngHolds the longitude of the map's current center.Access the value dynamically using JS: {{components.map1.center.lng}}.
center.googleMapUrlThis variable holds the URL of the location where the center marker is placed on the Map component.Access the value dynamically using JS: {{components.map1.center.googleMapUrl}}.
markersHolds the markers on the map, starting with Default markers. When Add new markers is on, markers the user adds by clicking the map are appended. Each marker is an object with lat and lng keys, and label if set.Access the values dynamically using {{components.map1.markers[0].lat}}.
selectedMarkerThe marker the user last clicked, as an object with lat and lng keys, and label if set.Access the value dynamically using JS: {{components.map1.selectedMarker.lat}}.
boundsThe visible area of the map, as an object with northEast and southWest corners. It is set after the user drags the map or selects a place from the search box.Access the value dynamically using JS: {{components.map1.bounds}}.
bounds.northEastIt holds the latitude and longitude of the north-east corner of the rectangle.Access the value dynamically using JS: {{components.map1.bounds.northEast.lat}} or {{components.map1.bounds.northEast.lng}}.
bounds.southWestIt holds the latitude and longitude of the south-west corner of the rectangle.Access the value dynamically using JS: {{components.map1.bounds.southWest.lat}} or {{components.map1.bounds.southWest.lng}}.

General​

Tooltip​

A Tooltip is often used to specify the extra information when the user hovers the mouse pointer over the component. Once a value is set for Tooltip, hovering over the element will display the specified string as the tooltip text. You can enter the content as Plain text, Markdown, or HTML by selecting the desired format from the toggle above the field.

Devices​

Property
Description
Expected Value
Show on desktopMakes the component visible in desktop view.You can set it with the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.
Show on mobileMakes the component visible in mobile view.You can set it with the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.

Styles​

Properties
Description
Expected Value
VisibilityToggle on or off to control the visibility of the component.You can programmatically change its value by clicking on the fx button next to it. If {{false}} the component will not be visible after the app is released. By default, it's set to {{true}}.
DisableThis is off by default, toggle on the switch to lock the component and make it non-functional.You can also programmatically set the value by clicking on the fx button next to it. If set to {{true}}, the component will be locked and becomes non-functional. By default, its value is set to {{false}}.
Box shadowAdd a shadow effect to the component by providing values to X, Y, Blur, Spread and Color.You can also programmatically set the value by clicking on the fx button next to it. Ex: 0px 0px 0px 0px #00000040.

Advanced​

Property
Description
Configuration Options
CSS classAdds a custom CSS class to the component, which can be targeted using Custom Styles for advanced styling.Enter one or more class names.
info

The Advanced section is available only if your plan has the Custom Styles feature enabled.