// Load the dynamic json file for highways, etc. // Ref: https://codepen.io/KryptoniteDove/post/load-json-file-locally-using-pure-javascript // Can also load .csv files function loadJSON(inFile, callback) { var xobj = new XMLHttpRequest(); // Assume XML unless filename ends with .json if (inFile.endsWith(".json")) { xobj.overrideMimeType("application/json"); } if (inFile.endsWith(".csv")) { xobj.overrideMimeType("text/csv"); } xobj.open('GET', inFile, true); xobj.onreadystatechange = function() { if (xobj.readyState == 4 && xobj.status == "200") { callback(xobj.responseText); } }; // We want ajax to ignore any cached responses xobj.setRequestHeader('If-Modified-Since', 'Sat, 01 Jan 2000 01:01:01 GMT') xobj.send(null); } /* Retrieve URL parameters passed to a web page @return a dictionary of key/value pairs */ function getQueryParms() { var items = {}; var query = window.location.search.substring(1); var parms = query.split("&"); // Examine each parameter for (var i = 0, max = parms.length; i < max; i++) { // check for trailing & with no param if (parms[i] === "") continue; // skip it var param = parms[i].split("="); // If it's valid add it to dictionary items[decodeURIComponent(param[0])] = decodeURIComponent(param[1] || ""); } return items }