I am using weather jQuery from the Wunderground API, and my jQuery is working well. However, the problem lies in the Wunderground API wind direction degrees. I want to display the wind degrees on a compass, and I found this answer on StackOverflow:
CSS:
#compass {
width: 380px;
height: 380px;
background-image:url('http://i.imgur.com/44nyA.jpg');
position: relative;
}
#arrow {
width: 360px;
height: 20px;
background-color:#F00;
position: absolute;
top: 180px;
left: 10px;
-webkit-transform:rotate(120deg);
-moz-transform:rotate(120deg);
-o-transform:rotate(120deg);
-ms-transform:rotate(120deg);
-moz-transition: all 1s ease;
-webkit-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
#compass:hover #arrow {
-webkit-transform:rotate(0deg);
-moz-transform:rotate(0deg);
-o-transform:rotate(0deg);
-ms-transform:rotate(0deg);
}
HTML:
<div id="compass">
<div id="arrow"></div>
</div>
I want to implement this CSS in my jQuery weather application, but I'm not sure how. Here is a demo of this CSS: http://jsfiddle.net/adb2A/
This is my jQuery code:
var x = document.getElementById("demo");
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
function showPosition(position) {
var location = position.coords.latitude + "," + position.coords.longitude;
jQuery(document).ready(function(weather) {
$.ajax({
url : "http://api.wunderground.com/api/eb7a37c339cfd624/geolookup/conditions/forecast10day/lang:AR/q/"+location+".json",
dataType : "jsonp",
success : function(data) {
var html = '<div style="color: black;text-align:right;direction: rtl;">';
html += '<h2>Current Temperature: ' + data.current_observation.temp_c + '</h2>'
html += '<h3>Feels Like: ' + data.current_observation.feelslike_c + '</h3>'
html += '<h3>Humidity: ' + data.current_observation.relative_humidity + '</h3>'
html += '<h3>Atmospheric Pressure: ' + data.current_observation.pressure_mb + '</h3>'
html += '<h3>Today\'s Precipitation: ' + data.current_observation.precip_today_in + '</h3>'
html += '</div>';
$("#news").append(html).hide().fadeIn("slow");
///10-day Forecast///
var dayArray = data.forecast.txt_forecast['forecastday'];
var html = '<div id="10days" style="color: black;text-align:right;direction: rtl;">';
for(var i=0; i<dayArray.length; i+=2)
html += '<div class="container center-block"><div class="row "><div class="col-md-8 col-md-offset-2"><h3>'+data.forecast.txt_forecast.forecastday[i]['title']+ " : " +data.forecast.txt_forecast.forecastday[i]['fcttext_metric']+'</h3></div>'
html += '</div></div>';
$("#10").append(html).hide().fadeIn("slow");
}
});
});
}