Guys, fair warning… if you pass to OpenWeatherMap Longitude numbers that are less than -180, or more than 180, OWM doesn’t know what to do and gives you an error 400 and no data.
I discovered this when I get my Lat/Lng numbers from Google Maps… when you drag Google Maps (drag pan left or right), Google Maps will give Lng numbers that are less than -180 depending on how far you drag the map from it’s original location! And when you pass something like -220.9093 to OpenWeatherMap, well, you get an error.
So before passing the Longitude number to OWM, do some checking.
function translateLongitude(lng){
if (lng < -180){
lng = lng + 360;
} else if (lng > 180) {
lng = lng - 360;
}
return lng;
}