Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Romanoff mromanoff

  • Las Vegas
View GitHub Profile
@Shivabeach
Shivabeach / #OpenWeathermap wind direction
Last active Jul 27, 2021
Open #weathermap conversion from degrees to direction. #degrees #direction #javascript
View #OpenWeathermap wind direction
$.getJSON("https://api.openweathermap.org/data/2.5/weather?id=4614214&units=imperial&APPID=openweathermap api code", function(data) {
var icon = "http://openweathermap.org/img/w/" + data.weather[0].icon + ".png";
var temp = Math.floor(data.main.temp);
var weather = data.weather[0].description;
var humid = data.main.humidity;
var windspeed = data.wind.speed + " mph";
var deg = Math.floor(data.wind.deg);
switch (true) {
case deg >= 360 && deg <= 21:
deg = "N";