Map widgets in ThingsBoard enable you to visualize entities and data on a map. They allow placing markers, zones, routes, and other geo-objects in space, which is especially useful for IoT solutions involving physical locations.

In ThingsBoard version 4.0, we've completely reworked our Map widgets to make them more flexible, easier to configure, and more powerful for working with geospatial data.

Use cases

Types of map widgets

Key improvements:

All of this — and more — is now available in the new Map widgets in ThingsBoard 4.0.

Adding a Map widget to the dashboard

To add a Map widget to the dashboard, follow these steps:

Map type

The first step in configuring the map widget is selecting the map type. ThingsBoard offers several map widgets, including Image Map, which allows you to use a custom background image as the map.

You can also configure map layers, enabling flexible switching between different map styles — such as satellite, hybrid, or custom layers — directly within the widget, with just a few clicks.


Adding a new map layer

You can add additional layer to the map widget by following these steps:

Now switch to the new layer on the widget.


In the “Layer settings”, you can also enable the “Reference layer” option — a special transparent layer that contains labeled map elements:

Overlays

Map items are visual elements displayed on a map widget to represent the spatial position, area, or influence zone of entities and data. These elements help visualize and interact with your devices, assets, or other tracked objects based on their spatial data.

ThingsBoard supports the following map item types:

Each map item type is bound to an entity and visualized based on its coordinates, provided as either attributes or telemetry. You can customize their appearance, behavior, and interaction rules directly in the widget settings.

Marker

Markers are commonly used to indicate the location of buildings, fixed sensors, vehicle tracking, or any other static or moving entities.

To be placed on the map, the entity must have coordinates as attributes or telemetry in the following format:

1
Latitude,Longitude

image

Place marker on map

To place a marker on the map, follow these steps:

The marker will appear on the map based on the specified coordinates.

Marker configuration

To configure a specific marker, switch to the map widget's edit mode. In the “Overlays” section, click the “gear” icon button next to the desired marker to open its configuration panel.


Datasource

Specify the data source for the marker. It can be:

If needed, use the data filter to refine the selection (e.g., filter by name or type).


Keys

Define the coordinate keys. By default, ThingsBoard uses latitude and longitude attributes as the default coordinate keys. If your entity uses custom key names, update them accordingly.

You can also define additional keys for dynamic display elements, such as marker color, tooltip content, Label text, etc.


Marker

This section defines how marker appear on the map. Customize the marker by selecting a different one from a variety of standard shapes and icons, adjusting its size and color, or use your own images for full visual flexibility.

Marker styling example: This example demonstrates how to configure marker styling so that its color changes automatically based on the value of the “state” key:

This approach visually reflects the status of the marker, greatly enhancing monitoring convenience.

Color-changing function based on the “state” key value:

1
2
3
4
5
6
7
8
9
10
var state = data.state;
if (state  !== '') {
  if (state == 'opened'){
    return 'green';
  } else {
    return 'red';
  }
} else {
  return 'grey';
}

Currently, the “state” key has the value “opened”, so the marker is displayed in green.

As soon as the value of the “state” key changes to anything else, the marker will turn red.


Label

The marker label is placed above the icon and, by default, displays the entity name. You can edit the label text or use a label function to show more dynamic information.

Label styling example:

1
2
3
4
<div style='position: relative; white-space: nowrap; text-align: center; font-size: 14px; top: 2px;'>
    <span style='margin-left: -500%;'></span>
    <div style='border: 2px solid #EC9704; border-radius: 10px; color: #000; background-color: #fff;  padding-left: 8px; padding-right: 8px; padding-top: 3px; padding-bottom: 3px;'>${entityName}</div>
</div>


Tooltip

Here you can configure a tooltip that appears when you click on or hover over the marker. Use the tooltip pattern or tooltip function to define more dynamic content. Alternatively, you can hide the tooltip altogether.

For example, you want the tooltip displays the status of a fueling station (open/closed) by retrieving the value from the “state” key, which is specified as one of the “Additional data keys” in the “Keys” section.
Use the function below and paste it into the Tooltip function window:

1
2
3
4
5
6
7
8
9
10
11
const stateObj = {
    "opened": "#4CAF50",
    "closed": "#D12730"
};

const currentState = data.state;

return `<div style="display: flex; justify-content: space-between; align-items: center; gap: 7px">
        <span style="font-weight: 600; font-size: 13px; line-height: 20px; color: #000000de">${data.entityName} is ${currentState}</span>
        <span style="width: 10px; height: 10px; border-radius: 100px; background-color: ${stateObj[currentState]}"></span>
    </div>`;

Tag actions

You can add an action to a tooltip as a tag. This can be to switch to a new dashboard state or another dashboard, to open an external URL, or even to initiate a custom action. Learn more about the available action types and how to configure them in the widget actions documentation.

First, you need to add a tag action and then reference its name in the tooltip function:

The function below already includes a reference to the tag action named “my-action”. If you gave your tag action a different name, please replace “my-action” with your actual tag name. Use this function to replace the previous tooltip function:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
const stateObj = {
  "opened": "#4CAF50",
  "closed": "#D12730"
};

const currentState = data.state;

return `<div style="text-align: center">
            <div style="display: flex; justify-content: space-between; align-items: center; gap: 7px">
                <span style="font-weight: 600; font-size: 13px; line-height: 20px; color: #000000de">${data.entityName} is ${currentState}</span>
                <span style="width: 10px; height: 10px; border-radius: 100px; background-color: ${stateObj[currentState]}"></span>
            </div>
            <link-act name='my-action'>Details</link-act>
    </div>`;

Click on the marker. In the tooltip that appears, you'll see a tag — click on it. The action you defined in the tag's settings will be executed.


Behavior

Set the behavior of the marker when you click it.


Groups

Markers can be grouped, allowing you to easily show or hide grouped elements later using the “Groups” tab.


Marker editing tools

You can use the built-in tools to perform operations on markers such as Add / Move / Delete. By default, these tools are disabled.

Check the boxes next to the tools you want to enable.

Adding marker

If your entity doesn't have coordinates set, you can manually place marker using the map widget tools — its coordinates will be automatically saved to the entity as attributes.

First, add the marker placement tool to the map:

You can now place the marker on the map:


Also, by selecting the checkboxes next to the desired tools, you'll be able to move or remove a marker.

Moving marker

Doc info icon

Don't forget to enable the “Move” tool in the marker settings under the “Edit marker” section.

To move the marker, click and hold the marker with your mouse, drag it to the new location, and then release the mouse button.

Removing marker

Doc info icon

Don't forget to enable the “Remove” tool in the marker settings under the “Edit marker” section.

To delete a marker, simply click on it, then click the trash bin icon in the menu at the bottom of the widget.


Use map markers clustering

Map clustering is a feature that automatically groups multiple markers located within the same visible area at a certain zoom level into a single cluster — a circular icon displaying the number of grouped items inside, instead of showing each marker individually.

This greatly improves map readability, especially when visualizing a large number of markers.

Polygon

The polygon is a flat shape defined by a finite number of points. It can be used to mark areas such as buildings, fields, service areas, visualize coverage areas or restricted regions, etc.

image


To display an entity as a polygon, it must have coordinates provided as attributes or telemetry in the following format:

1
[[1Latitude,1Longitude],[2Latitude,2Longitude],...,[nLatitude,nLongitude]]

where n - number of coordinates which polygon is described by.

Adding polygon

To place the polygon on the map, follow these steps:

Polygon configuration

To configure a specific polygon, switch to the map widget's edit mode. Then, in the “Polygon” tab under the “Overlays” section, click the “gear” icon button next to the desired polygon to open its configuration panel.


Datasource

Specify the polygon’s data source — it can be a device, an entity alias, or a function.

If needed, apply a filter to narrow down the selection.


Keys

Define the key that contains the polygon coordinates. By default, ThingsBoard uses “perimeter” as the polygon key. If your entity uses a different key name, make sure to update it here.

Additional data keys can be used for labels, tooltips, or to display extra information directly on the map.


Filling the polygon

Fill — defines how the polygon is filled on the map:

Stroke – defines the polygon outline:


Label

Configure the label displayed above the polygon. By default, the label shows the name of the entity linked to that polygon. You can manually edit the label text or use a label function to display dynamic information.

For example, the label can show the current status of the polygon, providing users with a quick and clear understanding of its state. If desired, you can also hide the label entirely.

1
2
3
4
<div style='position: relative; white-space: nowrap; text-align: center; font-size: 10px; top: -7px;'>
  <span style='margin-left: -500%;'></span>
  <div style='border: 2px solid #3388FF; border-radius: 5px; color: #000; background-color: #fff;  padding-left: 4px; padding-right: 4px; padding-top: 2px; padding-bottom: 2px;'>${entityLabel}</div>
</div>


Tooltip

Here you can configure a tooltip that appears when you click on or hover over the polygon. Use the tooltip pattern or tooltip function to define more dynamic content. Alternatively, you can hide the tooltip altogether.


Behavior


Groups

Polygons can be grouped, allowing you to easily show or hide grouped elements later using the “Groups” tab.


Polygon editing tools

You can use the built-in tools to perform operations on markers such as Add / Edit / Move / Delete. By default, these tools are disabled.

Check the boxes next to the tools you want to enable.


Adding polygon

If an entity doesn't have polygon coordinates set, you can manually place polygon using the map widget tools — its coordinates will be automatically saved to the entity as attribute.

First, add the polygon placement tool to the map:

You can now place the polygon on the map:


Editing polygon

Doc info icon

Don't forget to enable the “Edit” tool in the polygon settings under the “Edit polygon” section.

To resize the polygon, click on it — its vertices will appear. Drag any of the points to adjust the polygon’s size.


Moving polygon

Doc info icon

Don't forget to enable the “Move” tool in the polygon settings under the “Edit polygon**” section.

To move the polygon, click on the polygon, hold down the mouse button, and drag it to the new location.


Rotating polygon

TO rotate a polygon:


Cut polygon area

To cut out an area from a polygon:


Removing polygon

Doc info icon

Don't forget to enable the “Remove” tool in the polygon settings under the “Edit polygon” section.

To delete a polygon, simply click on it, then click the “trash bin” icon in the menu at the bottom of the widget.

Circle

Circle is a plane figure, boundary points of which are always the same distance away from a fixed central point. A circle can be used to define areas of influence, such as a Wi-Fi zone or the range of a sensor, and more. You may mark your assets and any other entities with a circle option.

Circle coordinates must follow this format:

1
{"latitude":CoordinateLatitude, "longitude":CoordinateLongitude, "radius":radius}

image

Add circle

You can mark your assets and any other entities with a circle using predefined coordinates received as attributes or telemetry. In this example, I'll use a device, which refers to assets of the type “Parking spots” as the data source.

To place the circle on the map, follow these steps:

Circle configuration

To configure a specific circle, switch to the map widget's edit mode. Then, in the “Circle” tab under the “Overlays” section, click the “gear” icon button next to the desired circle to open its configuration panel.


Datasource

Specify the circle's data source — it can be a device, an entity alias, or a function.
If needed, apply a filter to narrow down the selection.


Keys

Define the key that contains the circle coordinates. By default, ThingsBoard uses “perimeter” as the circle key. If your entity uses a different key name, make sure to update it here.

Additional data keys can be used for labels, tooltips, or to display extra information directly on the map.


Filling the circle

Fill — defines how the circle is filled on the map:

Stroke – defines the circle outline:


Label

Configure the label displayed above the circle. By default, the label shows the name of the entity linked to that circle. You can manually edit the label text or use a label function to display dynamic information.

For example, the label can show the current status of the circle, providing users with a quick and clear understanding of its state. If desired, you can also hide the label entirely.

1
2
3
4
<div style='position: relative; white-space: nowrap; text-align: center; font-size: 10px; top: -7px;'>
    <span style='margin-left: -500%;'></span>
    <div style='border: 2px solid #3B7FE1; border-radius: 5px; color: #000; background-color: #fff;  padding-left: 4px; padding-right: 4px; padding-top: 2px; padding-bottom: 2px;'>${entityLabel}</div>
</div>


Tooltip


Behavior

Set the behavior of the circle when you click it.


Groups

Circles can be grouped, allowing you to easily show or hide grouped elements later using the “Groups” tab.


Circle editing tools

You can use the built-in tools to perform operations on circles such as Add / Move / Delete. By default, these tools are disabled.

Check the boxes next to the tools you want to activate.


Adding circle

If an entity doesn't have circle coordinates set, you can manually place polygon using the map widget tools — its coordinates will be automatically saved to the entity as attribute.

First, add the circle placement tool to the map:

You can now place the circle on the map:


Editing circle

Doc info icon

Don't forget to enable the “Edit” tool in the circle settings under the “Edit polygon” section.

To resize the circle, click on it — the radius handle will appear. Drag this point to adjust the size of the circle. Once you're satisfied with the new size, click anywhere outside the circle to apply the current dimensions.


Moving circle

Doc info icon

Don't forget to enable the “Move” tool in the circle settings under the “Edit circle” section.

To move a circle, click on it, hold down the mouse button, and drag circle to the new location.


Removing circle

Doc info icon

Don't forget to enable the “Remove” tool in the circle settings under the “Edit polygon” section.

To delete a circle, simply click on it, then click the “trash bin” icon in the menu at the bottom of the widget.’

Additional datasources

Additional datasources are auxiliary data sources that can be used for processing, filtering, or overlaying data on the main entities. They are often used in map overlay features or tooltips when additional context or information needs to be provided.

Map controls

Map controls are settings for configuring map control buttons within the widget. They allow you to:

Map action buttons

Map action buttons are interactive buttons displayed on top of the map that trigger predefined actions. Learn more about the available action types and how to configure them in the widget actions documentation.

Let's consider an example of adding an action button that will allow users to place new objects on the map.

To ensure that newly created entities are immediately displayed on the map, you need to properly configure the data source.

Now, the action button labeled “Add building” has appeared at the top of the map.

The new marker is now added to the map.

Go to the “Assets” page — here you'll find your newly created asset, “Building A”.

Common map settings

Common map settings are the basic global settings for the Map widget in ThingsBoard. They define how the map behaves on load and what is displayed initially.

Appearance

Customize the widget's appearance.

Card appearance

Card appearance section controls the visual appearance of the widget on the dashboard.

Actions

You can add buttons to the widget header that will trigger predefined actions. You can learn more about the available action types at this link.


As an example, let&#39's add a button that allows users to place charging stations on the map:

To start, and to ensure that newly created entities are instantly displayed on the map, you need to properly configure the data source.

Now let's move on to configuring the action:

A new action button labeled “Add EV station” has now appeared at the top of the map. Let's use it.

Go to the “Assets” page — there you'll find your newly created asset, “EV station 1”.