Skip to content

Commit a8092c6

Browse files
authored
Merge pull request #1964 from mikewesthad/master
Fix for part of #1954: weather api -> earthquake api in loadJSON example
2 parents 70ded6c + d9f0c1a commit a8092c6

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

src/io/files.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,14 @@ p5.prototype.loadFont = function (path, onSuccess, onError) {
183183
* operation before setup() and draw() are called.</p>
184184
*
185185
* <div><code>
186-
* var weather;
186+
* // Examples use USGS Earthquake API:
187+
* // https://earthquake.usgs.gov/fdsnws/event/1/#methods
188+
* var earthquakes;
187189
* function preload() {
188-
* var url = 'http://api.openweathermap.org/data/2.5/weather?q=London,UK'+
189-
* '&APPID=7bbbb47522848e8b9c26ba35c226c734';
190-
* weather = loadJSON(url);
190+
* // Get the most recent earthquake in the database
191+
* var url = 'https://earthquake.usgs.gov/fdsnws/event/1/query?' +
192+
* 'format=geojson&limit=1&orderby=time';
193+
* earthquakes = loadJSON(url);
191194
* }
192195
*
193196
* function setup() {
@@ -196,10 +199,12 @@ p5.prototype.loadFont = function (path, onSuccess, onError) {
196199
*
197200
* function draw() {
198201
* background(200);
199-
* // get the humidity value out of the loaded JSON
200-
* var humidity = weather.main.humidity;
201-
* fill(0, humidity); // use the humidity value to set the alpha
202-
* ellipse(width/2, height/2, 50, 50);
202+
* // Get the magnitude and name of the earthquake out of the loaded JSON
203+
* var earthquakeMag = earthquakes.features[0].properties.mag;
204+
* var earthquakeName = earthquakes.features[0].properties.place;
205+
* ellipse(width/2, height/2, earthquakeMag * 10, earthquakeMag * 10);
206+
* textAlign(CENTER);
207+
* text(earthquakeName, 0, height - 30, width, 30);
203208
* }
204209
* </code></div>
205210
*
@@ -209,20 +214,22 @@ p5.prototype.loadFont = function (path, onSuccess, onError) {
209214
* <div><code>
210215
* function setup() {
211216
* noLoop();
212-
* var url = 'http://api.openweathermap.org/data/2.5/weather?q=NewYork'+
213-
* '&APPID=7bbbb47522848e8b9c26ba35c226c734';
214-
* loadJSON(url, drawWeather);
217+
* var url = 'https://earthquake.usgs.gov/fdsnws/event/1/query?' +
218+
* 'format=geojson&limit=1&orderby=time';
219+
* loadJSON(url, drawEarthquake);
215220
* }
216221
*
217222
* function draw() {
218223
* background(200);
219224
* }
220225
*
221-
* function drawWeather(weather) {
222-
* // get the humidity value out of the loaded JSON
223-
* var humidity = weather.main.humidity;
224-
* fill(0, humidity); // use the humidity value to set the alpha
225-
* ellipse(width/2, height/2, 50, 50);
226+
* function drawEarthquake(earthquakes) {
227+
* // Get the magnitude and name of the earthquake out of the loaded JSON
228+
* var earthquakeMag = earthquakes.features[0].properties.mag;
229+
* var earthquakeName = earthquakes.features[0].properties.place;
230+
* ellipse(width/2, height/2, earthquakeMag * 10, earthquakeMag * 10);
231+
* textAlign(CENTER);
232+
* text(earthquakeName, 0, height - 30, width, 30);
226233
* }
227234
* </code></div>
228235
*

0 commit comments

Comments
 (0)