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: The position of the control (one of the map corners). Possible values are 'topleft', 'topright', 'bottomleft' or 'bottomright'. Default is 'topright'.

    flow: A boolean on whether to render traffic flow/congestion layer on control click. Default is true.

    incidents: A boolean on whether to render traffic incidents layer on control click. Default is true.

    markets: A boolean on whether to render traffic markets layer on control click. Default is true.

    title: Text for the browser tooltip that appear on control hover. Default is 'Traffic'

    className: 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