HTML5 APPLICATIONS DEVELOPMENT MANUAL

(lu) #1

Now that we have that call all set, the data logged, we want to take


this outside of the call function. Remember that this beeing inside of a call


back, data variable isn’t available.


Let’s declare a variable outside of the getJSON. Delete the console


log, change the parameter to d, and assign that data we get to a larger data


variable.


We need to change the lat to an actual latitude and the lon to an actual


longitude. We can do that manually.


Let’s test the API key. From the example provided on the current call


weather data for one location by geographic coordinates, we can see the form


of the url to call the api.


api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid=


{apikey}

Free download pdf