Skip to main content

Route Modifiers Add-on

Contents

The Route Modifiers add-on allows control of the Route Modifiers layer on the map. Route modifiers are road segments you want the routing algorithm to avoid or favor when generating a route. Route modifiers are created in the ContentTools web tool, and linked to your API key.

Example setup

View a working demo and follow the steps below to create your own.

<link href="https://maps-sdk.trimblemaps.com/addon/trimblemaps-routemodifiers-1.0.5.css" rel="stylesheet">
<!-- Route Modifiers addon reference css -->
<script src="https://maps-sdk.trimblemaps.com/addon/trimblemaps-routemodifiers-1.0.5.js"></script>
<!-- Route Modifiers addon reference js -->
TrimbleMaps.APIKey = "YOUR_ACCESS_TOKEN";

var map = (window.map = new TrimbleMaps.Map({
  container: "map",
  style: TrimbleMaps.Common.Style.TRANSPORTATION,
  zoom: 12.5,
  center: [-77.01866, 38.888],
  region: TrimbleMaps.Common.Region.NA,
}));

// setup the Route Modifiers control
const modifierOptions = {
  isVisible: true,
};
const modifiersControl = new TrimbleMapsControl.RouteModifiers(modifierOptions);

// add control to map
map.addControl(modifiersControl, "top-right");

// once the map is loaded, load the AF Sets
myMap.once("load", () => {
  console.log("AF SETS from the ControlPanel: ", modifiers.getAFSets());
});

Show or Hide the Control

Parameter Type/Values Description
isVisible
Boolean
Specifies if the layer is should be displayed. Default true

Customize the Sets Displayed

You can customize the Route Modifier sets displayed by default on the map using the following settings.

Parameter Type/Values Description
showAll Boolean Sets whether all of the Route Modifiers sets are displayed on the map. Default is true.
selectedIds array of String or Number When showAll is set to true, Route Modifer sets listed by their IDs under selectedIDs are displayed by default on the map. Any remaining sets in your account are shown in the Route Modifiers control, but toggled off and need to be toggled on to be displayed on the map.
selectedPage Number For accounts with large numbers of Route Modifier sets, this setting loads the selected page of Route Modifiers for display in the control. Default is 1.
recordsPerPage Number The number of records per page. Default is 25.

Sample Code

var routemodifiersControl = new TrimbleMapsControl.RouteModifiers({
          selectedIds: [1002948, 1003261, 1003911],
          showAll: true,
          selectedPage: 1,
          recordsPerPage: 25,
        });
Last updated May 22, 2024.
Contents