MapQuest.js

L.mapquest.trafficControl(options)

A single button control that toggles on and off traffic layers. The trafficLayer, and incidentsLayer, and marketsLayer are all on by default but can be disabled with options. The position, title, and className of the control are customizable.

Syntax

L.mapquest.key = 'KEY';

var map = L.mapquest.map('map', {
  center: [34.0522, -118.2437],
  layers: [tileLayer],
  zoom: 12
});

map.addControl(L.mapquest.trafficControl());

Parameters

  • options object

    An object containing any of the following key value options: position, flow, incidents, markets, title, and className.

    • position String optional, defaults to 'topright'

      The position of the control (one of the map corners).

      Possible values are 'topleft', 'topright', 'bottomleft' or 'bottomright'.

    • flow Boolean optional, defaults to true

      A boolean on whether to render traffic flow/congestion layer on control click.

    • incidents Boolean optional, defaults to true

      A boolean on whether to render traffic incidents layer on control click.

    • markets Boolean optional, defaults to true

      A boolean on whether to render traffic markets layer on control click.

    • title String optional, defaults to 'Traffic'

      Text for the browser tooltip that appear on control hover.

    • className String optional

      A custom CSS class name to assign to the control.

    Example

    {
      position: 'topright',
      flow: true,
      incidents: true,
      markets: true,
      title: 'Traffic',
      className: ''
    }

Return Value

An L.Control object that can be added to a map with the addControl() function.

Visual Example