json mapquest traffic incidents
See original GitHub issueAnything I’m doing wrong?
Here’s the error and code
Ultimately, I want to display the following results set dynamically from JSON using tabulator.
<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js" integrity="sha256-eGE6blurk5sHj+rmkfsGYeKyZx3M4bG+ZlFyA7Kns7E=" crossorigin="anonymous"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/tabulator/3.3.1/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tabulator/3.3.1/js/tabulator.min.js"></script>
</head>
<body>
<div id="example-table"></div>
<script>
$("#example-table").tabulator("setData", "https://www.mapquestapi.com/traffic/v2/incidents?&outFormat=json&boundingBox=49.333400639691035%2C-122.77496337890625%2C49.15162235335807%2C-123.23638916015624&filters=construction%2Cincidents%2Cevent%2Ccongestion&key=PdA752LzJf3TG9HStfoASvzllR1Lb6FV");
//Build Tabulator
$("#example-table").tabulator({
height: "311px",
layout: "fitColumns",
placeholder: "No Data Set",
columns: [
{title: "Id", field: "incidents.Id", width: 200 },
],
rowClick: function (e, row) { //trigger an alert message when the row is clicked
alert("Row " + row.getData().id + " Clicked!!!!");
},
});
ajaxResponse: function ("url, params, response") {
//url - the URL of the request
//params - the parameters passed with the request
//response - the JSON object returned in the body of the response.
return response.incidents;
//return the data property of a response json object
},
}); </script>
</body>
</html>
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Traffic API - Incidents - GET - MapQuest Developer
The Traffic Incidents request returns a structured list of traffic incidents for a specified bounding box in JSON or XML formats, e.g., road...
Read more >Traffic API - Incidents - POST - MapQuest Developer
The Traffic Incidents request returns a structured list of traffic incidents for a specified bounding box in JSON or XML formats, e.g., road...
Read more >Traffic API - Overview | MapQuest API Documentation
The Traffic Incidents request returns a structured list of traffic incidents for a specified bounding box in JSON or XML formats, e.g., road...
Read more >Traffic Service - MapQuest API Documentation
Traffic incidents sample using the MapQuest Traffic API. ... MapQuest Traffic. /traffic/v2/incidents. Location. Output Format. JSON, XML. Advanced Options.
Read more >MapQuest JavaScript Library — v1.0 - L.mapquest.traffic
Documentation for the MapQuest.js traffic API interface. ... Queries the MapQuest Incidents API, and returns a JSON object with the list of incidents...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok got it, tnx again.
if you wanted to show just one of the properties of that object you can use dot notation to set it in the field property of the column definition “parameterizedDescription.crossRoad2”
if you wanted to view a JSON encoded view of the object you would need to use a custom formatter.
Cheers
Oli