Vehicle Restrictions

VERSION 0.2.3323

Vehicle Restrictions are the rules about what vehicles can use what roads. They have often been used to limit where vehicles such as trucks, delivery vans, and scooters can go. Climate and pollution regulations have added more rules, for example for electric vehicles (EVs) and high-emission vehicles. The Map Display SDK supports applying those restrictions to a specific vehicle as defined by the user.

The Vehicle restrictions API is available under the TomTomMap object. To enable vehicle restrictions in your app, load the pre-defined .restrictionsStyle.

map.styleContainer = .restrictionsStyle

Next, define the vehicle by importing:

import TomTomSDKCommon

This provides access to the Vehicle protocol

1let dimensions = try? VehicleDimensions(
2 weight: .init(value: 8000, unit: .kilograms),
3 axleWeight: .init(value: 4000, unit: .kilograms),
4 length: .init(value: 8340, unit: .millimeters),
5 width: .init(value: 4650, unit: .millimeters),
6 height: .init(value: 3445, unit: .millimeters)
8let vehicle = Truck(
9 maxSpeed: .init(
10 value: 120,
11 unit: .kilometersPerHour
12 ),
13 isCommercial: false,
14 combustionEngine: nil,
15 electricEngine: nil,
16 dimensions: dimensions,
17 modelID: "Fancy Truck"

Finally to show restrictions:

try? map.showVehicleRestrictions(vehicle: vehicle)

To hide restrictions:

try? map.hideVehicleRestrictions()

To apply changes after updating vehicle parameters:

try? map.updateVehicle(vehicle)