Interactive Routes

By default, routes are static. If you would like to your users to interact with the routes by moving the location of stop or dragging the routes, you just need to set the isDraggable property of the routing layer in the constructor to true.

<!DOCTYPE html>
        <meta charset="utf-8" />
        <link rel="stylesheet" href="" />
        <script src=""></script>
            body { margin: 0; padding: 0; }

            #map {
                position: absolute;
                top: 0;
                bottom: 0;
                width: 100%;

        <div id="map"></div>

            // Add two draggable routes.
            // Mouse over a route or a stop, then drag the mouse to add a new stop or changing a stop location.
            // Turn on or off route dragging by calling setDraggable method.
            TrimbleMaps.APIKey = 'YOUR_API_KEY_HERE';
            const map = new TrimbleMaps.Map({
                container: 'map',
                style: TrimbleMaps.Common.Style.TRANSPORTATION,
                center: new TrimbleMaps.LngLat(-74.566234, 40.49944),
                zoom: 8
            const myRoute = new TrimbleMaps.Route({
            routeId: 'myRoute',
            isDraggable: true,
            stops: [
                new TrimbleMaps.LngLat(-74.566234, 40.49944),
                new TrimbleMaps.LngLat(-74.629749, 40.26118)
            const myRoute2 = new TrimbleMaps.Route({
                routeId: 'myRoute2',
                isDraggable: true,
                routeColor: '#576571',
                stops: [
                    new TrimbleMaps.LngLat(-74.762360, 40.389078),
                    new TrimbleMaps.LngLat(-74.358442, 40.297086)
            map.on('load', function() {
                // myRoute2.setDraggable(false);
Last updated March 9, 2021.