Created
February 13, 2015 19:35
-
-
Save lmccart/a8d17ba8817412c10598 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x = 300; | |
var y = 300; | |
var speed = 0; | |
var input; | |
var button; | |
var url = "http://api.openweathermap.org/data/2.5/weather?q="; | |
function setup() { | |
createCanvas(windowWidth, windowHeight); | |
background(200); | |
input = createInput(); | |
input.position(50, 50); | |
button = createButton("submit"); | |
button.position(50, 80); | |
button.mousePressed(updateData); | |
} | |
function draw() { | |
background(200); | |
ellipse(x, y, 50, 50); | |
x += speed; | |
} | |
function handleData(weatherData) { | |
speed = weatherData.wind.speed; | |
} | |
function updateData() { | |
var city = input.value(); // text in the box | |
console.log(city); | |
// a loadJSON to get latlon from city | |
loadJSON('https://maps.googleapis.com/maps/api/geocode/json?address='+encodeURI(city), function(data) { | |
// get lat and lon | |
// call the second loadJSON to get images | |
}); | |
//var city = "NewYork,USA"; | |
loadJSON(url+city, handleData); | |
x = 300; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment