MapQuest.js

L.mapquest.traffic

A low-level class that is an interface to the MapQuest Traffic API, useful for direct use of traffic market and incident data.

L.mapquest.traffic.markets(callback)

Queries the MapQuest Markets API, and returns a JSON object with the list of markets.

Syntax

L.mapquest.key = 'KEY';

L.mapquest.traffic.markets(marketsCallback);

function marketsCallback(error, result) {
  console.log(result);
}

Parameters

  • callback required function

    A callback.

Return Value

The callback is called with arguments:

  1. An error, if any.
  2. The result. An example json object is below:
{
  "markets": [
    {
      "boundingBox": {
        "ul": {
          "lng": -82.110762,
          "lat": 41.359286
        },
        "lr": {
          "lng": -80.926346,
          "lat": 40.803517
        }
      },
      "mqURL": "https://www.mapquest.com/maps?traffic=1&city=Akron&state=OH",
      "zoom": 7,
      "state": "OH",
      "lng": -81.519202,
      "lat": 41.081401,
      "iconURL": "https://api.mqcdn.com/mqtraffic/stoplight.png",
      "city": "Akron / Canton"
    }
  ],
  "info": {
    "copyright": {
      "text": "© 2024 MapQuest, Inc.",
      "imageUrl": "https://api.mqcdn.com/res/mqlogo.gif",
      "imageAltText": "© 2024 MapQuest, Inc."
    },
    "statuscode": 0,
    "messages": []
  }
}

L.mapquest.traffic.incidents(options, callback)

Queries the MapQuest Incidents API, and returns a JSON object with the list of incidents in the given bounding box.

Syntax

L.mapquest.key = 'KEY';

L.mapquest.traffic.incidents({
    boundingBox: {
      ul: L.latLng(41.359286, -82.110762),
      lr: L.latLng(40.803517, -80.926346),
    },
    filters: ['incidents', 'construction', 'event', 'congestion']
  },
  incidentsCallback
);

function incidentsCallback(error, result) {
  console.log(result);
}

Parameters

  • options object

    An object containing the boundingBox and filters parameters.

    boundingBox: The area where to search for incidents.

    filters: The types of incidents to return.

    Possible values are: incidents, construction, event, congestion

    Default: incidents, construction

    Example

    {
      boundingBox: {
        ul: L.latLng(41.359286, -82.110762),
        lr: L.latLng(40.803517, -80.926346),
      },
      filters: ['incidents', 'construction', 'event', 'congestion']
    }
  • callback required function

    A callback.

Return Value

The callback is called with arguments:

  1. An error, if any.
  2. The result. An example json object is below:
{
  "incidents": [
    {
      "fullDesc": "One lane closed due to maintenance work on California Street Eastbound between 18th Street and 19th Street.",
      "lng": -104.9886,
      "severity": 2,
      "shortDesc": "California Street E/B : Lane closed between 18th Street and 19th Street ",
      "endTime": "2013-08-02T01:59:00",
      "type": 1,
      "id": "330627538",
      "startTime": "2013-02-04T19:00:00",
      "impacting": true,
      "tmcs": [],
      "eventCode": 0,
      "iconURL": "https://api.mqcdn.com/mqtraffic/const_mod.png",
      "lat": 39.7481
    }
  ],
  "mqURL": "https://www.mapquest.com/maps?traffic=1&latitude=39.73976&longitude=-104.9848",
  "info": {
    "copyright": {
      "text": "2017 MapQuest, Inc.",
      "imageUrl": "https://api.mqcdn.com/res/mqlogo.gif",
      "imageAltText": "2017 MapQuest, Inc."
    },
    "statuscode": 0,
    "messages": []
  }
}