Skip to content
Stand with Ukraine flag

Route Map

The Route Map widget visualizes the complete path traveled by entities over a selected time period. Use it to review historical routes — vehicle trips, delivery paths, asset movement — displayed as a static line on a map. An optional timeline control panel can be enabled for interactive route playback.

Route Map is one of four map widgets in ThingsBoard, each serving a distinct purpose:

WidgetPrimary use
MapDisplays current entity locations in real time.
Image MapUses a custom background image. Best for floor plans, parking lots, and indoor layouts.
Trip MapAnimated route replay with full timeline controls. Best for step-by-step movement analysis.
Route MapRenders the full historical path as a static route line. Best for reviewing complete trips at a glance.

What sets Route Map apart:

  • Draws the route from timeseries latitude/longitude data rather than the latest value only.
  • Supports the Polylines overlay for displaying fixed infrastructure routes like bus lines or pipelines.
  • Timeline control panel is available but disabled by default — enable it when interactive playback is needed.
  • Supports Trips, Markers, Polygons, Circles, and Polylines overlays simultaneously on the same map.
  1. Open the dashboard and switch to edit mode.
  2. Click Add widget at the top, or the Add new widget icon in the center of the screen.
  3. Open the Maps widget bundle.
  4. Select Route Map.
  5. Configure the widget settings, then click Add.

The time window defines the period over which route data is loaded and displayed.

  • Use dashboard time window: The widget inherits the global time range set on the dashboard. All widgets using this mode stay synchronized when the dashboard time range changes.

  • Use widget time window: The widget uses its own independent time range. Select a mode:

    • Realtime — the window slides forward as time passes, always showing the most recent interval (like “last 1 day”). Default for Route Map.
    • History — a fixed range with a specific start and end. Use this to inspect a particular past trip.
  • Display time window: Toggle the time interval label on the widget card.

For details on time window settings, see Time window.

Choose between Map (tile-based) and Image (custom background).

Renders the route on a standard tile map. Configure one or more layers:

  • Label: Display name shown in the layer switcher on the widget.
  • Provider: OpenStreet, Google, HERE, Tencent, or Custom (enter a tile server URL).
  • Layer: Tile style — Mapnik, HOT, WorldStreetMap, WorldTopoMap, WorldImagery, Roadmap, etc. Available options depend on the provider.
  • Reference layer: A transparent overlay with labeled map elements (streets, borders). Configure via the layer gear icon menu.

Click Add layer to configure additional switchable layers. Users switch between layers using the layer icon button directly on the widget.

Overlays are the visual elements rendered on the map. Each overlay type binds to its own data source and is configured independently.

The Trips overlay draws the path traveled by an entity as a continuous line, based on timeseries latitude/longitude data. A marker is rendered at the most recent position along the route.

Add a trip: Click Add trip, select a data source, define coordinate keys, and click Save.


Datasource

Select the entity providing timeseries coordinates: Function, Device, or Entity (entity alias). Apply a filter to narrow the selection. Expand More datasources to add additional data sources.


Keys

  • Latitude key: Timeseries key containing latitude values (default: latitude).
  • Longitude key: Timeseries key containing longitude values (default: longitude).
  • Additional data keys: Extra telemetry keys (like speed, status) available in label and tooltip functions.

Appearance — Marker

The icon displayed at the entity’s position on the route. Three display modes:

  • Shape: Select a built-in shape; set size (px) and color. Use a color function (JavaScript) to change the marker color dynamically based on telemetry values.
  • Icon: Select a built-in icon; set size and color.
  • Image: Provide an image URL, or use a marker image function that returns { url, size, offset }. Set a custom marker image size.

Marker offset — fine-tune the anchor point position (Horizontal, Vertical; 0–1 range).

Rotate marker — rotates the marker icon to match the direction of movement. Set an Offset angle (degrees) to adjust the base orientation.


Appearance — Label

Text shown above the marker:

  • Pattern (default): Use template variables like ${entityName}, ${entityLabel}, or any data key.
  • Function: Return an HTML string based on data values.

Appearance — Tooltip

Popup shown on marker interaction:

  • Pattern / Function: Define content as a template or a JavaScript function.
  • Tooltip trigger: Show on click or show on hover.
  • Auto-close tooltips: Close when clicking elsewhere on the map.
  • Tag actions: Add named action links inside the tooltip using <link-act name='action-name'>Label</link-act>. Clicking the link triggers the configured widget action.

Behavior

On click — action triggered when the marker is clicked. Available types: Do nothing, Navigate to new dashboard state, Update current dashboard state, Navigate to other dashboard, Custom action, Custom action (HTML template), Mobile action, Open URL.


Position conversion (Image map type only)

A JavaScript function that converts the original relative x/y coordinates of the marker before rendering on the image. Useful when markers from multiple entities share the same position and need to be spread apart, or when coordinates need to be remapped to a custom image scale.

Function signature: f(origXPos, origYPos, data, dsData, aspect)

Parameters:

  • origXPos: number — original relative x coordinate (0 to 1).
  • origYPos: number — original relative y coordinate (0 to 1).
  • data — entity data for this trip point: entity properties and telemetry from the configured datasource.
  • dsData — all data from all data layers, including additional datasources.
  • aspect: number — image map aspect ratio (width / height).

Must return { x: number, y: number } — new relative coordinates, each from 0 to 1.

Default (pass-through):

return {x: origXPos, y: origYPos};

Example — detect markers with same positions and place them with minimum overlap:

var xPos = data.xPos;
var yPos = data.yPos;
var locationGroup = dsData.filter((item) => item.xPos === xPos && item.yPos === yPos);
if (locationGroup.length > 1) {
const count = locationGroup.length;
const index = locationGroup.indexOf(data);
const radius = 0.035;
const angle = (360 / count) * index - 45;
const x = xPos + radius * Math.sin(angle * Math.PI / 180) / aspect;
const y = yPos + radius * Math.cos(angle * Math.PI / 180);
return {x: x, y: y};
} else {
return {x: xPos, y: yPos};
}

Path

  • Path: Enable to display the route line. Set line thickness (px) and color.
  • Path decorator: Directional symbols rendered along the path:
    • Decorator symbol: Arrow or Dash.
    • Size and color of the symbol.
    • Decorator arrangement: Start offset, End offset, and Repeat interval (all in px).
  • Points: Dot markers at each recorded data point. Set size (px) and color.
    • Point tooltip: Popup at each recorded point. Configure pattern or function, tooltip trigger, auto-close, and tag actions.

Groups

Assign a group name. Groups appear in the Groups panel on the widget, where entire groups can be shown or hidden at once.

Additional datasources provide telemetry or attributes from entities not directly displayed on the map. Use them in overlay functions for conditional logic — color-changing markers, enriched tooltips, or computed display values based on data from related devices.

  • Source: Entity type — Function, Device, or Entity alias.
  • Data keys: Telemetry or attribute keys to read from the entity.

Click Add datasource to configure more.

Configure the interactive controls available on the widget.

Position — placement of the controls panel: Top-left, Top-right, Bottom-left, or Bottom-right.

Zoom actions — enable zoom via:

  • Scroll: Mouse wheel zoom.
  • Double click: Zoom in on double-click.
  • Control buttons: Show + / − zoom buttons on the map.

Scale — display a distance scale bar: Metric (km / m) or Imperial (mi / ft).

Timeline control panel — disabled by default. When enabled, adds interactive playback controls for stepping through the route:

  • Time step: How much time advances per animation frame (ms).
  • Speed options: Comma-separated list of playback speed multipliers shown to the user (e.g., 1, 5, 10, 15, 25).
  • Timestamp: Toggle to display the current playback time. Select a date/time format from the dropdown.
  • Snap to real location: When enabled, the marker snaps to the nearest actual data point during playback. Expand to configure a JavaScript filter function — receives data and dsData, returns true if the point should be used as an anchor (e.g., filter by time interval: return data.time % 1000 === 0).

Add custom buttons overlaid on the map. Each button triggers a predefined action when clicked.

Each button has a Label, Icon, Color, and Action.

Available action types: Do nothing, Navigate to new dashboard state, Update current dashboard state, Navigate to other dashboard, Custom action, Custom action (HTML template), Mobile action, Open URL, Place map item.

Click Add button to configure more buttons.

For action configuration details, see Widget actions.

  • Fit map bounds to cover all markers: Auto-adjusts zoom and position on load to fit all visible map items. Enabled by default.
  • Default map center position: Initial map center coordinates (latitude, longitude) used when auto-fit is disabled.
  • Default map zoom level: Initial zoom level. Higher values zoom in closer (e.g., 7 for country level, 15 for street level).
  • Limit of entities to load: Maximum entities loaded simultaneously. Prevents performance issues with large datasets (default: 16384).
  • Title: Widget header label. Disabled by default. Use ${entityName} or ${entityLabel} as pattern variables, or enter a static string.
  • Card icon: Icon displayed next to the title in the header. Set size (px), alignment, and color.
  • Background: Card background color.
  • Show card buttons: Toggle Data export and Fullscreen buttons in the widget header.
  • Card border radius: Corner rounding in px (default: 0px).
  • Card padding: Inner spacing between content and card edge in px (default: 8px).

Add Widget header button actions — icon buttons in the widget header that trigger a configured action when clicked.

See Widget actions for available action types and configuration.

Goal: Visualize a bus’s real-time movement and its complete route over the last hour.

Download the example widget

You can download a preconfigured Route Map widget for this example and reuse it in your own dashboards.

After importing, update these settings to match your environment:

  • Datasource: select your actual device (for example, your own Tracker1).
  • Data keys: replace telemetry key names if they differ (latitude, longitude, speed, status).
  • Map provider: choose the provider your ThingsBoard instance supports.

Prerequisites

You need a device that continuously sends latitude, longitude, speed, and status as timeseries telemetry.

  1. Create a device named Tracker1.

  2. Download the emulator script. It connects to thingsboard.cloud by default — replace the host with your own ThingsBoard instance URL.

  3. Run the script:

    Terminal window
    node timeseries-map-bus.js $ACCESS_TOKEN

    where $ACCESS_TOKEN is the device access token from the device details page.

    The emulator requires Node.js 12 or higher.

  4. Confirm that Tracker1 is receiving telemetry with keys latitude, longitude, speed, and status.

Step 1: Add the widget

Open the dashboard in edit mode and add a Route Map widget.

Step 2: Configure the widget

Time window

Set the time interval:

  • Realtime
  • Last 1 hour
  • Aggregation: None.

Disable the display time window toggle.


Map type

Select Map and configure three layers:

LabelProviderLayer
RoadmapOpenStreetMapnik
SatelliteOpenStreetHOT
HybridOpenStreetWorldImagery

Overlays

Overlays ⇾ Trips and click Add trip.

Configure the trip:

  • Datasource: Device — Tracker1
  • Latitude key: latitude, Longitude key: longitude
  • Additional data keys: speed, status

Configure marker and label:

  • Marker: Shape — bus icon, size 34, color #E89623
  • Label pattern:
<div style="position: relative; white-space: nowrap; text-align: center; font-size: 12px; top: 5px;"><span style="border-radius: 10px; background-color: #fff; padding-left: 12px; padding-right: 12px; padding-top: 4px; padding-bottom: 4px;">${entityName}</span></div>

Configure the tooltip function:

var speed = data['speed'];
var res;
if (speed > 0) {
res = "<b>${entityName}</b><br/><b>Speed:</b> " + String(speed) + " km/h";
} else {
res = "<b>${entityName}</b><br/><b>Status:</b> At the stop";
}
return res;

Save the trip configuration.


Appearance

Disable the Title display.

Click Add to insert the widget into the dashboard. Resize and reposition as needed, then save the dashboard.

Result

The map now shows the bus’s complete route over the last hour as a continuous path connecting all recorded positions.

Route not displayed:

  • Verify the device has timeseries records with the latitude and longitude keys matching the configured key names (default: latitude, longitude).
  • Check the time window — if the range is too narrow, no data points may fall within it.
  • Confirm the datasource entity is correct and key names are spelled exactly as they appear in the telemetry.

Markers not visible:

  • Confirm the entity has latitude and longitude attributes or telemetry populated.
  • Make sure the coordinate key names in the widget configuration match the entity’s actual key names.

Polyline not shown:

  • Confirm the entity has the polyline attribute with the correct key name.
  • Verify the attribute value follows the expected format: [[lat1,lng1],[lat2,lng2],...].

Map loads blank:

  • For Google Maps, HERE, or Tencent — verify the API credentials are configured in ThingsBoard system settings.
  • For OpenStreetMap, no credentials are required.

Timeline panel missing:

  • Enable the Timeline control panel toggle under Map controls.