课程: Hands-On Introduction: JavaScript

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Add a location selector

Add a location selector

- [Instructor] As we wrap things up, let's add one more feature to our JavaScript-based weather app. I want the visitor to be able to enter any location and get the current weather for that location. For that to happen, we first need to convert the location data into something that works with the API, and the good news is OpenWeather has a special geocoding API for this particular purpose. The geocoding API allows us to pass any city, state code, and country code into the API and in return we get an array of objects for all the cities that match that location. When we look at the data you see, for each of those locations, we get the latitude, and longitude and we can use these two fields to populate our request for weather data. For this to work, we need a couple of pieces in place, so in between the previous movie and this one, I made some changes to our project. Specifically, I've added a new location form. Now…

内容