MapQuest-GL.js

mqgl.Map.traffic

The traffic object for drawing/removing incidents and flows.

Methods

mqgl.Map.traffic.draw()

Draws traffic flows and incidents on the map. If the zoom level is 9 or lower, only a clickable traffic market icon will appear. Clicking on the traffic market icon will zoom in on the market and display the traffic flow and incidents.

Syntax

var map = new mqgl.Map('map', 'KEY', {
  center: [-118.2437, 34.0522],
});

map.load( () => {
  map.traffic.draw()
});

Parameters

None

Return Value

A Promise

Visual Example

mqgl.Map.traffic.remove()

Removes all traffic items from the map.

Syntax

var map = new mqgl.Map('map', 'KEY', {
  center: [-118.2437, 34.0522],
});

map.load( () => {
  map.traffic.draw();
  setTimeout( () => {
    map.traffic.remove();
  }, 2000);
});

Parameters

None

Return Value

A Promise

mqgl.Map.traffic.isOn()

Determines if traffic is drawn on the map.

Syntax

var map = new mqgl.Map('map', 'KEY', {
  center: [-118.2437, 34.0522],
});

map.load( () => {
  map.traffic.draw().then( () => {
    console.log(map.traffic.isOn())
  });
});

Parameters

None

Return Value

Boolean