Skip to main content

Truck Restrictions

The truck restrictions layer allows you to display truck restrictions on your map. The controls listed below can be used to interact with the Truck Restrictions layer.

Truck Restrictions Layer

Create a TruckRestriction object and add it to the map.

const truckRestriction = new TrimbleMaps.TruckRestriction();
myMap.on('load', function() {
    truckRestriction.addTo(myMap);
});

Once the TruckRestriction layer is loaded and ready to use, make it visible.

myMap.on('truckrestriction', () => {
    truckRestriction.setVisibility(true);
})

Get the visibility of the truck restriction layer.

const restrictionsVisible = truckRestriction.isVisible();

Toggle the visibility of the truck restrictions layer.

truckRestriction.toggleVisibility();

Truck Restrictions Click Control

The click control makes the truck restrictions on the map clickable. A popup with restriction details is shown when the restriction is clicked.

Truck Restrictions Click Control

var ctrl = new TrimbleMaps.TruckRestrictionClickControl();
myMap.addControl(ctrl);

Truck Restrictions Filter Control

The Filter control allows the user to filter the restrictions based on category or truck attributes. Be sure to call the Filter() function once the TruckRestrictions are loaded.

Truck Restrictions Filter Control

var ctrlFilter = new TrimbleMaps.TruckRestrictionFilterControl({
    isVisible: true,
    category: 'All',
    vehicleOptions: {
        trkWeight: 13000,
        trkWidth: 70,
        vehicleType: TrimbleMaps.Common.VehicleType.TRUCK
    }
});
myMap.addControl(ctrlFilter);
myMap.on('truckrestriction', () => {
    truckRestriction.setVisibility(true);
    ctrlFilter.Filter()
})
Last updated September 2, 2022.