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

Traffic layers

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.

Traffic API Flow Tiles

Traffic Flow Tiles are available in two formats: vector (.pbf) and raster (.png). Vector tiles provide the possibility for visual customization and better visual experience. Therefore, we recommend using the vector tiles for map and traffic display. Raster tiles are especially suitable for low performance devices.

Vector traffic flow tiles are used by default for traffic flow in the Maps SDK. Traffic flow tiles are available from map zoom levels: 0 to 22.

You can switch to raster traffic by using these methods:

_

mapView.trafficTileStyle = TTRasterTileType.setStyle(.relative)
mapView.trafficIncidentsStyle = .raster
self.mapView.trafficTileStyle = [TTRasterTileType setStyle:TTRasterStyleRelative];
self.mapView.trafficIncidentsStyle = TTTrafficIncidentsStyleRaster;

You can switch to vector traffic by using these methods:

_

mapView.trafficTileStyle = TTVectorTileType.setStyle(.relative)
mapView.trafficIncidentsStyle = .vector
self.mapView.trafficTileStyle = [TTVectorTileType setStyle:TTVectorStyleRelative];
self.mapView.trafficIncidentsStyle = TTTrafficIncidentsStyleVector;

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

Traffic API Flow Tiles style types are represented in the SDK as an enum. 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