Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for part of #1954: weather api -> earthquake api in loadJSON example #1964

Merged
merged 2 commits into from
May 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions src/io/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,14 @@ p5.prototype.loadBytes = function () {
* operation before setup() and draw() are called.</p>
*
* <div><code>
* var weather;
* // Examples use USGS Earthquake API:
* // https://earthquake.usgs.gov/fdsnws/event/1/#methods
* var earthquakes;
* function preload() {
* var url = 'http://api.openweathermap.org/data/2.5/weather?q=London,UK'+
* '&APPID=7bbbb47522848e8b9c26ba35c226c734';
* weather = loadJSON(url);
* // Get the most recent earthquake in the database
* var url = 'https://earthquake.usgs.gov/fdsnws/event/1/query?' +
* 'format=geojson&limit=1&orderby=time';
* earthquakes = loadJSON(url);
* }
*
* function setup() {
Expand All @@ -196,10 +199,12 @@ p5.prototype.loadBytes = function () {
*
* function draw() {
* background(200);
* // get the humidity value out of the loaded JSON
* var humidity = weather.main.humidity;
* fill(0, humidity); // use the humidity value to set the alpha
* ellipse(width/2, height/2, 50, 50);
* // Get the magnitude and name of the earthquake out of the loaded JSON
* var earthquakeMag = earthquakes.features[0].properties.mag;
* var earthquakeName = earthquakes.features[0].properties.place;
* ellipse(width/2, height/2, earthquakeMag * 10, earthquakeMag * 10);
* textAlign(CENTER);
* text(earthquakeName, 0, height - 30, width, 30);
* }
* </code></div>
*
Expand All @@ -209,20 +214,22 @@ p5.prototype.loadBytes = function () {
* <div><code>
* function setup() {
* noLoop();
* var url = 'http://api.openweathermap.org/data/2.5/weather?q=NewYork'+
* '&APPID=7bbbb47522848e8b9c26ba35c226c734';
* loadJSON(url, drawWeather);
* var url = 'https://earthquake.usgs.gov/fdsnws/event/1/query?' +
* 'format=geojson&limit=1&orderby=time';
* loadJSON(url, drawEarthquake);
* }
*
* function draw() {
* background(200);
* }
*
* function drawWeather(weather) {
* // get the humidity value out of the loaded JSON
* var humidity = weather.main.humidity;
* fill(0, humidity); // use the humidity value to set the alpha
* ellipse(width/2, height/2, 50, 50);
* function drawEarthquake(earthquakes) {
* // Get the magnitude and name of the earthquake out of the loaded JSON
* var earthquakeMag = earthquakes.features[0].properties.mag;
* var earthquakeName = earthquakes.features[0].properties.place;
* ellipse(width/2, height/2, earthquakeMag * 10, earthquakeMag * 10);
* textAlign(CENTER);
* text(earthquakeName, 0, height - 30, width, 30);
* }
* </code></div>
*
Expand Down