---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/examples/cases/traffic_control.md
  - https://yandex.com.tr/dev/jsapi-v2-1/doc/ru/v2-1/examples/cases/traffic_control.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com.tr/dev/jsapi-v2-1/doc/en/llms.txt

# Traffic control

<iframe id="LIVE-EXAMPLE" style="width:100%;height: 400px;border-radius: 8px;border: 1px solid rgba(92, 94, 102, 0.14);" frameBorder="0" src="https://yastatic.net/s3/front-maps-static/maps-front-jsapi-v2-1/examples/2/out/s3-cases/en/traffic_control/index.html" allow="fullscreen"></iframe>

<a target="_blank" rel="noopener noreferrer" style="display: inline-block;margin-top: 10px;cursor: pointer;border-radius: 4px;padding: 9px 12px;background: #151515;color: white;text-decoration: none;font-weight: 500" href="https://codesandbox.io/p/sandbox/gc77m7?file=index.html">Open in CodeSandbox</a>

<div id="references">
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ready">ready</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map">Map</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/control.TrafficControl">control.TrafficControl</a>
</div>
<p>
    A <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/dg/concepts/controls">control</a> is a visual object that allows the user to manipulate the map (for example, move the map, change its type, or change the zoom).
</p>
<p>
    Each control is implemented by a separate class from the 'control' namespace (for example, <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/control.Button">control.Button</a>).
</p>
<p>
    The "Traffic" control can be enabled either via the 'trafficControl' key, or by creating an instance of the <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/control.TrafficControl">control.TrafficControl</a> class. When creating an instance of the class, you can specify the initial state of the control.
</p>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>
    <html>
        <head>
            <title>Examples. "Traffic" control</title>
            <meta
                http-equiv="Content-Type"
                content="text/html; charset=UTF-8"
            />
            <!--
            Set your own API-key. Testing key is not valid for other web-sites and services.
            Get your API-key on the Developer Dashboard: https://developer.tech.yandex.ru/keys/
        -->
            
            
            
        </head>
        <body>
            <div id="map"></div>
        </body>
    </html>
    ```

-   traffic_control.js

    ```js
    ymaps.ready(init);

    function init() {
        var myMap = new ymaps.Map("map", {
            center: [56.136, 40.39],
            zoom: 10,
            controls: [],
        });

        // Creating the "Traffic" control.
        var trafficControl = new ymaps.control.TrafficControl({
            state: {
                // Displaying traffic "Now".
                providerKey: "traffic#actual",
                // Begin immediately showing traffic on the map.
                trafficShown: true,
            },
        });
        // Adding the control to the map.
        myMap.controls.add(trafficControl);
        // Getting a reference to the "Now" traffic provider and enabling the display of information points.
        trafficControl
            .getProvider("traffic#actual")
            .state.set("infoLayerShown", true);
    }
    ```

{% endlist %}
