_sv_11
October 13, 2020, 3:21pm
1
Hi @all
I want to load data from a weather-api and also i want to load images from my computer.
But when i run the code the following error is displayed. (in german)
Can someone help me?
//----------------------------------------------------------------------------------
// Declaration
let wind;
let temp;
let gef_Temp;
let wolken;
let sunrise;
let sunset;
let bild;
let temp_png;
let position;
let spritedata;
let spritesheet;
let Ort = 'neuler';
let apiKey = '8e197bf081174d4f7200c08bfe170a88';
let data
let url = 'https://api.openweathermap.org/data/2.5/weather?q=' + Ort + ',de&units=metric&appid=' + apiKey + '&lang=de';
//----------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
function preload() {
data = loadJSON(url)
temp_png = loadImage('weather_icons/png/039-thermometer.png')
}
//----------------------------------------------------------------------------------
function setup() {
createCanvas(800, 500);
position = createVector(width / 2, height / 2);
Wetterdaten(data);
image(temp_png, 10, 80, 100, 100)
}
//----------------------------------------------------------------------------------
function Wetterdaten(data) {
Ort = data.name
console.log(Ort)
}
function draw() {
background(255);
Header();
}
//----------------------------------------------------------------------------------
function Header() {
// Hintergrund und Rahmen
fill(200)
stroke(0, 0, 0)
strokeWeight(5)
rect(5, 5, (width - 10), (height - 10), 10)
// Ueberschrift
noStroke()
textFont('Ribeye')
textSize(36);
textStyle(BOLD);
// fill('rgb(50,50,255)')
fill(0)
textAlign(CENTER);
text('Simons Wetterdienst', width / 2, 50)
push()
stroke(0)
translate(width / 2, 60)
strokeWeight(5)
line(-210, 0, 210, 0)
pop();
}
//----------------------------------------------------------------------------------
I want to add 1 more solution to what @gotoloop proposed: embedding the images as BASE64 inside your code. This will work fine, but only for small images:
var dog = `iVBORw0KGgoAAAANSUhEUgAAASwAAADQBAMAAABPdEGQAAAAMFBMVEXDmWr////o6OleNhCpflFx
SSaGXTrHnnGRbk3EsaDSxrrg2NGumoibgmvkT1CrRDWIfASmAAAACXBIWXMAAA7EAAAOxAGVKw4b
AAAVbklEQVR4nO2dS2wUV7qAS7ptF2RWXQvk7nIv3BIe4wZppD9Varh4LpIb4ntXKEVbkI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