Sorry, you need to enable JavaScript to visit this website.

Traffic layers

Traffic layers

Give your users the ability to see real time traffic in your mobile apps.

With Traffic Flow tiles your users will have information about congestion,
the speed of traffic on different road segments, and the difference between that speed and the
free-flow speed on the same road segments. You can find more information and details about
Traffic Flow tile parameters on
Vector Traffic Flow tiles or
Raster Traffic Flow tiles.

Traffic flow tiles

Traffic flow tiles are available in two formats: vector (.pbf) and raster (.png).
Vector tiles provide a possibility for visual customization and better visual experience by means of a style sheet.
Also, the vector tiles contain certain traffic information (e.g. road type, traffic level, etc), check Traffic flow tags
in Vector Flow Tiles documentation
for details.

Vector traffic flow tiles are used by default for traffic flow in Maps SDK.
You can switch to raster traffic flow tiles by using the method:

_

tomtomMap.getTrafficSettings().turnOnRasterTrafficFlowTiles();
tomtomMap.trafficSettings.turnOnRasterTrafficFlowTiles()

 

You can change back to vector traffic tiles by using the method:

_

tomtomMap.getTrafficSettings().turnOnVectorTrafficFlowTiles();
tomtomMap.trafficSettings.turnOnVectorTrafficFlowTiles()

 

Vector Traffic Flow Tiles listener

Additionally, you can get details about the specific traffic flow of the road fragment (e.g. current speed, travel times, etc)
from Flow Segment Data
service which is integrated in Maps SDK. This service is designed to work alongside the traffic flow tiles to support clickable
flow data visualizations. This is handled for you in the Maps SDK. Set the following listener:

_

tomtomMap.getTrafficSettings().setOnTrafficFlowClickListener(new DefaultOnTrafficFlowClickListener(tomtomMap));
tomtomMap.trafficSettings.setOnTrafficFlowClickListener(DefaultOnTrafficFlowClickListener(this))

 

Then you need to implement the following interface, which informs you if any traffic flow segment was clicked:

/**
 * Callback executed when traffic flow on the map is clicked.
 */
public interface OnTrafficFlowClickListener {
    /**
     * Callback executed when traffic flow on the map is clicked.
     *
     * @param mapPoint point on screen resolved as a location.
     * @param trafficFlows  list of traffic points under clicked place on the map.
     */
    boolean onTrafficFlowClick(MapPoint mapPoint, List<TrafficFlow> trafficFlows);
}

which informs what place on the map is clicked and what traffic flows are clicked.

By default implementation, when you click on the specific traffic flow segment, a balloon with details is shown:

tomtomMap.getTrafficSettings().showTrafficFlowBalloon(pointOnScreen, new TrafficFlowMapBalloon(flows));

 

Default listener dismisses a traffic balloon when information about traffic is not available:

tomtomMap.getTrafficSettings().dismissTrafficBalloon();

 

To set a custom view for the traffic balloon, the TrafficFlowBalloonViewAdapter should be implemented and set by TrafficSettings#setTrafficFlowBalloonViewAdapter method.
A default implementation is set as follows:

_

tomtomMap.getTrafficSettings().setTrafficFlowBalloonViewAdapter(new TrafficFlowBalloonViewAdapter.Default());
tomtomMap.trafficSettings.setTrafficFlowBalloonViewAdapter(TrafficFlowBalloonViewAdapter.Default())

 

Vector Traffic Incidents Tiles listener

You can get details about the specific traffic incidents flow and traffic incidents pois (e.g. current speed, travel times, etc)
from Vector Flow Tiles
service which is integrated in Maps SDK. This service is designed to work alongside the traffic tiles to support clickable
incident data visualizations. This is handled for you in the Maps SDK. Set the following listener:

_

tomtomMap.getTrafficSettings().setOnTrafficIncidentsClickListener(new DefaultOnTrafficIncidentClickListener(tomtomMap));
tomtomMap.trafficSettings.setOnTrafficIncidentsClickListener(DefaultOnTrafficIncidentClickListener(this))

 

Then you need to implement the following interface, which informs you if any traffic incident (poi, cluster, flow) was clicked:

/**
 * Callback executed when traffic flow on the map is clicked.
 */
public interface OnTrafficFlowClickListener {
    /**
     * Callback executed when traffic flow on the map is clicked.
     *
     * @param mapPoint point on screen resolved as a location.
     * @param trafficFlows  list of traffic points under clicked place on the map.
     */
    boolean onTrafficFlowClick(MapPoint mapPoint, List<TrafficFlow> trafficFlows);
}

which informs what place on the map is clicked and what traffic flows are clicked.

By default implementation, when you click on the specific traffic incident, a balloon with details is shown for incident flows:

tomtomMap.getTrafficSettings().showTrafficIncidentBalloon(mapPoint, TrafficIncidentsMapBalloon.ofFlows(incidentsFlows));

and for incident pois:

tomtomMap.getTrafficSettings().showTrafficIncidentBalloon(mapPoint, TrafficIncidentsMapBalloon.ofPois(incidentsPois));

 

Default implementation of incident click listener zoom the map when traffic cluster is clicked:

tomtomMap.getUiSettings().setCameraPosition(
        CameraPosition
                .builder(mapPoint.getPosition())
                .zoom(countNewZoom(incidentsCluster))
                .build()
);

 

To set a custom view for the traffic incident balloon, the TrafficIncidentsBalloonViewAdapter should be implemented and set by TrafficSettings#setTrafficIncidentsBalloonViewAdapter method.
A default implementation is set as follows:

_

tomtomMap.getTrafficSettings().setTrafficIncidentsBalloonViewAdapter(new TrafficIncidentsBalloonViewAdapter.Default());
tomtomMap.trafficSettings.setTrafficIncidentsBalloonViewAdapter(TrafficIncidentsBalloonViewAdapter.Default())

 

Traffic type and styles

Traffic tiles styles are represented in the SDK as Java data classes.
Traffic flow tiles style types are represented in the SDK as data classes.

The available vector traffic flow styles are listed below and can be set by method:

_

tomtomMap.getTrafficSettings().turnOnVectorTrafficFlowTiles(new TrafficFlowType.RelativeTrafficFlowStyle()); //default
tomtomMap.getTrafficSettings().turnOnVectorTrafficFlowTiles(new TrafficFlowType.AbsoluteTrafficFlowStyle());
tomtomMap.getTrafficSettings().turnOnVectorTrafficFlowTiles(new TrafficFlowType.RelativeDelayTrafficFlowStyle());
tomtomMap.trafficSettings.turnOnVectorTrafficFlowTiles(TrafficFlowType.RelativeTrafficFlowStyle()) //default
tomtomMap.trafficSettings.turnOnVectorTrafficFlowTiles(TrafficFlowType.AbsoluteTrafficFlowStyle())
tomtomMap.trafficSettings.turnOnVectorTrafficFlowTiles(TrafficFlowType.RelativeDelayTrafficFlowStyle())

 

The available raster traffic flow styles are listed below and can be set by method:

_

UiSettings uiSettings = tomtomMap.getUiSettings();
//default
uiSettings.turnOnRasterTrafficFlowTiles(new RelativeTrafficFlowStyle());
uiSettings.turnOnRasterTrafficFlowTiles(new AbsoluteTrafficFlowStyle());
uiSettings.turnOnRasterTrafficFlowTiles(new RelativeDelayTrafficFlowStyle());
uiSettings.turnOnRasterTrafficFlowTiles(new ReducedSensitivityTrafficFlowStyle());
//default
tomtomMap.uiSettings.turnOnRasterTrafficFlowTiles(TrafficFlowType.RelativeTrafficFlowStyle())
tomtomMap.uiSettings.turnOnRasterTrafficFlowTiles(TrafficFlowType.AbsoluteTrafficFlowStyle())
tomtomMap.uiSettings.turnOnRasterTrafficFlowTiles(TrafficFlowType.RelativeDelayTrafficFlowStyle())
tomtomMap.uiSettings.turnOnRasterTrafficFlowTiles(TrafficFlowType.ReducedSensitivityTrafficFlowStyle())

 

Sample use case: You want to visualize traffic information in your app so your users can adjust
their commute based on traffic information.

Use the code snippets below in your app to enable and visualize the vector traffic flow layer on
the map:

_

tomtomMap.getTrafficSettings().turnOnVectorTrafficFlowTiles();
tomtomMap.trafficSettings.turnOnVectorTrafficFlowTiles()

 

You can turn off traffic flow by using the method:

_

tomtomMap.getTrafficSettings().turnOffTraffic();
tomtomMap.getTrafficSettings().turnOffTrafficFlowTiles();
tomtomMap.trafficSettings.turnOffTraffic()

 

Information about set style:

_

VectorTrafficFlowType style = tomtomMap.getTrafficSettings().getTrafficVectorFlowStyle();
val style = tomtomMap.trafficSettings.trafficVectorFlowStyle

 

Traffic incidents

Traffic incidents style types are represented in the SDK as a data class. The available
traffic incidents options are the following:

  • Vector incidents tiles and POIs:

_

tomtomMap.getTrafficSettings().turnOnVectorTrafficIncidents();
tomtomMap.trafficSettings.turnOnVectorTrafficIncidents()

 

  • Raster incidents tiles:

_

tomtomMap.getTrafficSettings().turnOnRasterTrafficIncidents();
tomtomMap.trafficSettings.turnOnRasterTrafficIncidents()

 

You can turn off traffic incidents by using the method:

_

tomtomMap.getTrafficSettings().turnOffTrafficIncidents();
tomtomMap.trafficSettings.turnOffTrafficIncidents()

 



image

Traffic vector flow layer on vector map.

image

Traffic raster flow shown on raster map.

image

Traffic vector incidents layer with the S1 file style.

image

Traffic raster incidents layer in sample app.

image

Traffic vector incidents and raster flow layer on raster map.

image

Traffic raster incidents and raster flow layer on raster map.

image

No Vector traffic in sample app.

image

No Raster traffic in sample app.

You are here