Skip to content
Stand with Ukraine flag

Lesson 1. Maps & Entity Tables

In this lesson, you will model a smart-building scenario — two buildings, two offices, and four IoT devices — then build a Buildings dashboard with an OpenStreet Map widget and an Entities table widget.


Assets represent real-world objects such as buildings and office spaces.

In this step, create four assets: Building A, Building B, Office A, and Office B.
Each asset should also include attributes such as building coordinates, address, floor information, office phone number, and other relevant details that will be used in the next step.

You can create each asset manually or import multiple assets at once using bulk provisioning feature. After import, all buildings and offices will have the required attribute data.

  1. Download building-assets.csv
  2. Go to Entities ⇾ Assets.
  3. Click + Add asset ⇾ Import asset.
  4. Drag the building-assets.csv file into the import window and click Continue.
  5. Verify the delimiter ,, then click Continue.
  6. Map the data between the uploaded file columns and the ThingsBoard data types using the table below.
  7. Click Continue, then OK.
KeyColumn typeBuilding ABuilding B
nameNameBuilding ABuilding B
typeType building building
latitudeServer attribute40.7591240.75901
longitudeServer attribute-73.97600-73.96997
addressServer attribute645 5th Ave, New York641 Lexington Ave, New York
emailServer attribute[email protected][email protected]
phoneServer attribute+121 244 55 66+121 555 66 77
contactPersonServer attributeThomas JohnsonJack Williams

Check the import result.

  1. Download office-assets.csv
  2. Click + Add asset ⇾ Import asset.
  3. Drag the office-assets.csv file into the import window and click Continue.
  4. Verify the delimiter ,, then click Continue.
  5. Map the data between the uploaded file columns and the ThingsBoard data types using the table below.
  6. Click Continue, then OK.
KeyColumn typeOffice AOffice B
nameNameOffice AOffice B
typeType office office
floorServer attribute34
emailServer attribute[email protected][email protected]
phoneServer attribute+1 121 333 4455+1 121 666 5522
officeManagerServer attributeEmma Johnson[email protected]

Check the import result.


Devices are IoT entities that collect data from their environment, send it to ThingsBoard, and respond to RPC commands.

Create four devices—an indoor air quality sensor, an energy meter, a water flow meter, and another indoor air quality sensor—using the bulk provisioning feature as well. Each sensor has its own type and location coordinates, which will be used later to display them on the office map.

Save the following content as devices.csv:

name,type,label,xPos,yPos
SD-001,air-sensor,Indoor Air Quality Sensor,0.51,0.68
EM-002,energy-sensor,Energy Meter,0.14,0.95
WM-003,water-sensor,Water Flow Meter,0.14,0.32
AM-307,air-sensor,IAQ Sensor,0.49,0.38

Or download a pre-made one.

  1. Go to Entities ⇾ Devices.
  2. Click + Add device ⇾ Import device.
  3. Drag the devices.csv file into the import window and click Continue.
  4. Verify the delimiter, then click Continue.
  5. Map columns: name ⇾ Name, type ⇾ Device Profile, label ⇾ Label.
  6. Click Continue, then OK.

The Attributes tab for each device displays server attributes, including active, xPos, and yPos.


Feature Relations define directed connections between entities.

Link each building to its offices, and each office to its devices.

Buildings
├── Building A
│ ├── Office A
│ │ ├── SD-001
│ │ ├── EM-002
│ │ └── WM-003
│ └── Office B
│ └── AM-307
└── Building B

Link offices to Building A:

  1. Open Building A details and go to the Relations tab.
  2. Set direction to From, then click +.
  3. Set relation type to Contains and entity type to Asset.
  4. Select Office A and Office B, then click Add.

Link devices to Office A:

  1. Open Office A details, go to Relations ⇾ From, and click +.
  2. Set relation type to Contains and entity type to Device.
  3. Select SD-001, EM-002, and WM-003, then click Add.

Repeat the same steps for Office B, selecting only AM-307.


A Dashboard is where you visualize and interact with your assets and devices.

Create a dashboard in a separate group for the buildings scenario.

  1. Go to Dashboards.
  2. Click + Add dashboard ⇾ Create new dashboard.
  3. Enter dashboard title (e.g., Buildings).
  4. Add dashboard to the group:
    • Enter Buildings in the “Groups” field
    • Click Create a new one!.
    • Confirm creating dashboard group by clicking Add.
  5. Click Add to confirm creating dashboard.
  6. Save the dashboard by clicking the Save button in the upper-right corner of the screen.

Add a Map widget to display Building A and Building B.
Each building must have latitude and longitude attributes to place markers correctly. Additional info—address, contact details, and image—will be shown in a popup when a marker is clicked.

Start with the preparatory work below.

Building images need to be uploaded to the Image gallery, which serves as a centralized repository for storing and managing images. They will be used in the tooltip of the map widget. You can use the Building A and Building B images from this guide or upload your own images.

Download the sample images:

  1. Go to Resources ⇾ Image gallery.
  2. Click Upload image and upload the photo for Building A, then for Building B.
  3. Click the Embed image icon next to each uploaded image, copy and save the generated links. You will need these links in the next step.

Add the appropriate image URL for Building A and Building B as the buildingImage server attribute.

  1. Go to the Assets, open the Building A details and navigate to the Attributes tab.
  2. Click + and add an attribute with the image URL corresponding to this building.
  3. Repeat the same for Building B, using its corresponding image URL.

With images uploaded and attributes set, add the OpenStreet Map widget to the dashboard.

  1. Navigate to Dashboards ⇾ Buildings.
  2. Click + Add widget.
  3. Open the Buildings dashboard, enter edit mode, and click Add widget.
  4. Select Maps ⇾ Map.
  5. Open the widget configuration and switch to the Advanced tab.
  6. Select Positron layer for OpenStreet map type.
  7. Scroll to the Overlays section and click Add marker on the Markers tab.
  8. Set Source to Entity, enter building as entity alias name, and click Create a new one!.
  9. Create alias:
    • Set filter type to Asset type
    • Specify asset type to building
    • Click Add
  1. Open marker configuration and verify that the marker uses the building alias and latitude/longitude keys are set.
  2. Configure data keys, including latitude, longitude, and add additional data keys: address, email, phone, and buildingImage.
  3. In the Appearance section, use an image as the marker:
    • Download the image from the provided link
    • Upload it to Image gallery and use
    • Set the marker size to 60 pixels
    • Click Apply
  1. Verify that the custom marker image is applied.

  2. Configure the marker label to display the entity name.

    <div style="position: relative; white-space: nowrap; text-align: center; font-size: 12px; top: -5px;">
    <span style="border-radius: 10px; background-color: #fff; padding: 4px 12px;">${entityName}</span>
    </div>
  1. Configure the tooltip function to display additional building details.

    const address = data.address ? data.address : 'N/A';
    const email = data.email ? data.email : 'N/A';
    const phone = data.phone ? data.phone : 'N/A';
    const buildingImage = data.buildingImage ? data.buildingImage : 'Building image not found';
    return '<div style="display:flex;flex-direction:column;font-family:\'Roboto\';font-weight:500;font-size:14px;line-height:24px;letter-spacing:0.25px;color:#29313C;margin-bottom:5px">' +
    `<img style="width: 300px; height: auto" src=${buildingImage}>` +
    '<div style="margin-top:5px;">${entityName}</div>' +
    '<div style="display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:10px">' +
    '<div style="font-size:11px;line-height:16px;font-weight:500;color:rgba(0, 0, 0, 0.38);">Address</div>' +
    '<div style="font-size:12px;line-height:20px;font-weight:500;color:#29313C;letter-spacing:0.25px;text-align:right;">'+ address +'</div>' +
    '</div>' +
    '<div style="display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:10px">' +
    '<div style="font-size:11px;line-height:16px;font-weight:500;color:rgba(0, 0, 0, 0.38);">Email</div>' +
    '<div style="font-size:12px;line-height:20px;font-weight:500;color:#29313C;letter-spacing:0.25px;text-align:right;">'+ email +'</div>' +
    '</div>' +
    '<div style="display:flex;flex-direction:row;align-items:baseline;justify-content:space-between;gap:10px">' +
    '<div style="font-size:11px;line-height:16px;font-weight:500;color:rgba(0, 0, 0, 0.38);">Phone</div>' +
    '<div style="font-size:12px;line-height:20px;font-weight:500;color:#29313C;letter-spacing:0.25px;text-align:right;">'+ phone +'</div>' +
    '</div>' +
    '</div>';
  1. Scroll down and set card padding to 0.

  2. Navigate to the Widget card tab and turn off displaying the widget title.

  3. Adjust advanced widget styles and apply CSS provided below:

    .leaflet-popup-content { width: auto !important; margin: 8px; }
    a.leaflet-popup-close-button {
    font-size: 20px; color: black;
    backdrop-filter: blur(5px);
    background: rgba(255, 255, 255, 0.35);
    border-radius: 2px; top: 17px; right: 17px;
    }
  1. Click Add to finish.

Position the widget in the top-right corner of the dashboard and resize it by dragging its edges. Once the layout is adjusted, click Save in the top-right corner to apply the changes.

Now click on any building image to display a tooltip with information about it.


The map shows building locations, but a list view makes it easy to scan building details at a glance. Add an Entities table widget to display both buildings alongside their addresses.

  1. In dashboard edit mode, click Add widget.
  2. Select Tables ⇾ Entities table.
  3. Set datasource to the building alias.
  4. Add address as a column key.
  5. Set the card title to Buildings list.
  6. Uncheck all Show card buttons options.
  7. Click Add, resize the widget, then save the dashboard.

Apply a background image and global CSS styles to give the dashboard a polished, professional look.

  1. Click Settings on the dashboard toolbar.

  2. In Advanced settings ⇾ Dashboard CSS, paste:

    .tb-widget-container > .tb-widget {
    border-radius: 8px;
    box-shadow: 0px 4px 10px rgba(23, 33, 90, 0.5);
    }
    .tb-dashboard-page .tb-widget-container > .tb-widget .leaflet-popup a.tb-custom-action {
    font-family: 'Roboto';
    font-weight: 500;
    font-size: 14px;
    line-height: 20px;
    letter-spacing: 0.25px;
    border-bottom: none;
    color: #00695C;
    }

    This CSS snippet applies styles to elements with the .tb-widget class that are direct children of the .tb-widget-container. It specifies border-radius: 8px, which gives the element soft rounded corners, and box-shadow: 0px 4px 10px rgba(23, 33, 90, 0.5), which creates a semi-transparent shadow with a subtle blur, offset by 4 pixels downward, adding visual depth, and specifies opacity: 0.9 to make the element slightly transparent, allowing for some background visibility while maintaining the content’s visibility.

  3. Download the sample background or use your own.

  4. Scroll to Background image and click Browse from gallery.

  5. Upload the background image if not already present, select it, and click Apply.

  6. Save the layout settings, then save the dashboard.


As a result your dashboard should look like this: