Here’s my version of the Weather App. It starts with your ‘home’ location and displays weather at your home location. But you can drag the map anywhere, and it will display the weather at the new location you just dragged into.
PS: Rate limiting may take effect, if calls to Weathermap happens too fast and by too many users.
You may need to use a proxy server calling the weather API (due to the mixed https/http problem).
I’m using cors-anywhere. Here’s a snippet
function getWeather(myLat, myLng){
// myLng = translateLongitude(myLng); // if you're not using draggable maps, don't need this
$.ajax({
method: "GET",
url: "https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/weather",
// API key is required, assign to appid
data: { lat: myLat, lon: myLng, appid: '0ba5350ff17a90b6f0b3bb63cf06f3a9' }
})
.done(function( msg ) {
// after successful call, we can now display values back to html page
var weather = msg;
// blah blah blah ...
// lots of stuff goes here, replacing html with the actual weather data
}); // end of ajax call
}
For some reason, the above URL doesn’t work from my end anymore…
but here’s my updated projects, all-in-one. (quote/weather/tribute/wiki)