In my sketch I want to type a City in a textfield and insert this Information into my API-URL:
var Stadt='Berlin';
function setup() {
createCanvas(500,500);
textfield = createInput ();
textfield.changed(newText);
loadJSON('https://api.openrouteservice.org/geocode/search?'+
'api_key=5b3ce3597851110001cf6248a7e197414b934680bff4449c39f000cc'+
'&text='+Stadt+'', gotData);
}
function newText (){
console.log (textfield.value());
}
function gotData(data) {
var city = data.features;
var lon = city[0].geometry.coordinates[0];
var lat = city[0].geometry.coordinates[1];
fill(0)
noStroke();
ellipse (lat+100, lon+100, 10, 10);
}
I can use textfield.value()
to load the information into my sketch, but how can i now change var Stadt
to the textfieldvalue()
?