jQuery(document).ready(function($) {
var maLatitude; /*Variable gobale contenant la latitude*/
var maLongitude; /*Variable gobale contenant la longitude*/
if (navigator.geolocation)
navigator.geolocation.getCurrentPosition(showPosition);
else
alert("Votre navigateur supporte pas la géolocalisation, essayez de mettre à jour votre navigateur!");
});
function showPosition(position){
maLatitude= position.coords.latitude;
maLongitude= position.coords.longitude;
$.ajax({
url : "http://api.wunderground.com/api/API_KEY ... ude+".json",
dataType : "jsonp",
success : function(parsed_json) {
var location = parsed_json['location']['city'];
var temp_c = parsed_json['current_observation']['temp_c'];
var tempRessentie = parsed_json['current_observation']['feelslike_c'];
var wicon = parsed_json['current_observation']['icon'];
var condition = parsed_json['current_observation']['weather'];
var vent_kmh = parsed_json['current_observation']['wind_kph'];
var rafales = parsed_json['current_observation']['wind_gust_kph'];
var visibilite = parsed_json['current_observation']['visibility_km'];
$("div.ville").append("" + location + " "+
"" + temp_c + " °C"+
" Temp. ressentie : "+tempRessentie+" °C"+
""+
"
"+
""+condition+""+
"Vent : "+vent_kmh+" km/h"+
"Rafales : "+rafales+" km/h"+
"Visibilité : "+visibilite+" km");
}
});
}
Подробнее здесь: https://stackoverflow.com/questions/214 ... rew-myself