xxxxxxxxxx
var APIURL = 'https://data.cityofnewyork.us/resource/f7b6-v6v3.json'
var thestuff = {};
var isready = false;
var themenu;
var inp;
var boro = "Brooklyn";
var fontsize = 18;
var inputfield, button;
function preload () {
thestuff = loadJSON(APIURL,goforit);
}
function setup(){
createCanvas (windowWidth, windowHeight);
background (255)
stroke(0);
fill(0);
textSize(fontsize);
//inputfield = createInput('Brooklyn');
//inputfield.position(40, 150);
// button = createButton('click me');
// button.position(40,180);
//button.mousePressed(clickme); // what function runs when I click the button
//asktheweather(inputfield.value());
themenu = createSelect();
//.option([contentValue],[value])
//If 1 param, it's both content AND
//value. Values treated as strings.
themenu.option("Bronx");
themenu.option("Brooklyn");
themenu.option("Manhattan");
themenu.option("Queens");
themenu.option("Staten Island");
themenu.position(width*0.8, height*0.2);
//If changed, call select1Changed
themenu.changed(menuchanged);
// input box:
// inp = createInput('');
// inp.position(50, 550);
// inp.size(100, 20);
// inp.style('font-size', '20px');
// inp.input(settext);
}
function draw(){
if(isready)
{
background (25,25,112);
fill(255)
let y = fontsize;
let i = 0;
while(y<height)
{
fill(255);
if(!(i in thestuff)) break; // get out of this loop if i start looking for keys that aren't there
if(thestuff[i].borough==boro)
{
let s = '';
s+=thestuff[i].borough + ': ';
s+=thestuff[i].facility_type + ' - ';
//fill(255,255,0);
s+=thestuff[i].facility_name + ' ';
text(s, 20, y);
y+=fontsize;
}
i++;
}
}
}
function menuchanged()
{
boro = themenu.value();
}
function settext()
{
}
function goforit(){
isready = true;
//console.log(thestuff);
}