You are viewing an older version of MapQuest.js. Check out the latest version.
A low-level class that is an interface to the MapQuest Traffic API, useful for direct use of traffic market and incident data.
Queries the MapQuest Markets API, and returns a JSON object with the list of markets.
L.mapquest.key = 'KEY';
L.mapquest.traffic.markets(marketsCallback);
function marketsCallback(error, result) {
  console.log(result);
}The callback is called with arguments:
{
  "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": []
  }
}Queries the MapQuest Incidents API, and returns a JSON object with the list of incidents in the given bounding box.
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);
}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
{
  boundingBox: {
    ul: L.latLng(41.359286, -82.110762),
    lr: L.latLng(40.803517, -80.926346),
  },
  filters: ['incidents', 'construction', 'event', 'congestion']
}A callback.
The callback is called with arguments:
{
  "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": []
  }
}