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 API 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 API Flow tile parameters on Online Vector Traffic Flow tiles, or Online Raster Traffic Flow tiles.

To turn on/off traffic flow or incidents use these methods:

_

mapView.trafficIncidentsOn = true
mapView.trafficFlowOn = true
self.mapView.trafficIncidentsOn = YES;
self.mapView.trafficFlowOn = YES;

Vector Traffic Flow Tiles Delegate

Additionally, you can get details about the specific traffic flow or incident of the road fragment (e.g., current speed, travel times, etc.) from the Flow Segment Data service which is integrated in the Maps SDK. This service is designed to work alongside the traffic to support clickable flow and incidents data visualizations. This is handled for you in the Maps SDK. The SDK provides default implementation of trafficDelegate which is TTMapTrafficDelegateDefault.

_

mapView.trafficDelegate = TTMapTrafficDelegateDefault()
self.mapView.trafficDelegate = [[TTMapTrafficDelegateDefault alloc] init];

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

_

let callout = TTMapTrafficCalloutFactory.create(with: trafficIncidentPoi)
mapView.display(callout, atPosition: coordinate)
TTMapTrafficCallout* callout = [TTMapTrafficCalloutFactory createWithIncidentPoi:trafficIncidentPoi];
[mapView displayTrafficCallout:callout atPosition:position];

The default implementation of an incident click listener zooms the map when the traffic cluster is clicked:

_

let newZoom = mapView.zoom + 1
mapView.closeTrafficCallout()
if(newZoom < mapView.maxZoom) {
  mapView.center(on: position, withZoom: newZoom)
}
double newZoom = mapView.zoom + 1;
[mapView closeTrafficCallout];
if(newZoom < mapView.maxZoom) {
    [mapView centerOnCoordinate:position withZoom:newZoom];
}

Traffic type style

Important
I In May 2020 methods used for switching between vector and raster tiles got deprecated and will be removed after one year. From that point to display raster tiles it will be required to reload the style to one which contains raster layers. Before deprecation period is over map is still going to be initialized with the style that contains raster and vector tiles. However to prepare yourself for the migration please check how to init map that is described here.

When Maps SDK is launched with a style containing raster sources for Traffic Flow appropriately set according to style definition then you can switch to Raster Traffic The available traffic flow styles are the following:

_

.relative,
.absolute,
.relativeDelay,
.reducedSensitivity
TTRasterStyleRelative,
TTRasterStyleAbsolute,
TTRasterStyleRelativeDelay,
TTRasterStyleReducedSensitivity
image

Traffic vector flow layer on vector map

image

Traffic raster flow shown on raster map

image

Traffic vector incidents layer on vector map

image

Traffic raster incidents layer on vector map

image

Traffic vector incidents and vector flow layer on vector map

image

Traffic raster incidents and raster flow layer on raster map