Displaying toll roads

This article explains how to visualize toll roads on a map. Note that the vehicleClosed The term vehicle describes what is being routed or planned for. Vehicles are used in route calculation, distance matrix calculation and effectively also in tour planning. In route calculation, vehicle properties like overall size, weight and speed are in focus. In tour planning, it is vehicle properties like capacity and availability. Commonly a vehicle is motorized, like a truck - including its trailer or a car. However also a bike or even a pedestrian are included in this definition. attributes and the time dependency are not taken into account to display the toll roads; that means a road can be rendered as tolled even if it is free of charge for your vehicle or at the time you drive on it. Nevertheless the map may contain different sets of toll roads for example when it is already known that at some point in the future new roads will be tolled.


This feature gives you the ability to see the toll roads and the toll locations.


Check if the following prerequisites are fulfilled before you start with the use case:

  • Installed and licensed PTV xMap Server
  • Installed PTV Map containing toll data
  • Installed and activated license key toll

Programming Guide

When using the RESTClosed REST (Representational State Transfer) represents a World Wide Web paradigm, consisting of constraints to the design of components which results in a better performance and maintainability. API to build a tiled map, the REST operation tile is part of the following URL, by means individual tiles can be requested:

http://hostname:50000/services/rest/XMap/tile/{zoomLevel}/{x}/{y}?storedProfile={profileClosed A profile is a collection of parameters used to configure the request. Full profiles consist of a number of specialized sub-profiles like the VehicleProfile which describes the properties of a vehicle.}

Concrete values in URL template have to be defined for zoomlevel, x and y coordinates, specifying the map section of the corresponding tile.

To display toll roads on a map with common content, the parameter layers has to be specified in the URL enabling all base layers and toll.


To obtain a map which contains only toll roads, the parameter layers has to be specified in the URL enabling only toll.


With the request option timeConsideration set to SNAPSHOT it is possible to define a point in time for which the toll roads should be displayed.



In the example below, which is based on the one from Displaying a Basic Interactive Map, Toll roads are displayed on a tiled map using the Leaflet toolkit depending on the toll data detail level. The function determineTollLayer sends a dataInformation request and checks the toll detail level of the map. If there is detailed toll data available for at least some parts of the map, the toll layer is requested in addition to the other base layers.

var referenceTime = '2018-10-01T10:00:10+01:00'; var map = new L.Map('map', { center: [41.52, -71.37], zoom: 12 }); var tollLayer = ''; // Determine the toll detail level function determineTollLayer() { var urlPath = xServerUrl + '/services/rest/XRuntime/experimental/dataInformation'; $.ajax(urlPath).always(function(response){ if (response) { if (response.mapFeatures.tollFeatures && (response.mapFeatures.tollFeatures.detailLevel == "DETAILED" || response.mapFeatures.tollFeatures.detailLevel == "MIXED")) { tollLayer = ',toll'; } } }); }; determineTollLayer(); // Add layer with PTV map and Feature Layer Toll roads var tileUrl = xServerUrl + '/services/rest/XMap/tile/{z}/{x}/{y}' + '?storedProfile=silkysand&layers=labels,transport,background' + tollLayer + '&timeConsideration=SNAPSHOT&referenceTime=' + encodeURIComponent(referenceTime); new L.TileLayer(tileUrl, { minZoom: 3, maxZoom: 18, noWrap: true }).addTo(map);

Related Topics

The following topics might be relevant for this use case.