如何获得mu openweather API以使用地理位置?这是我目前的
HTML代码:
Get my location.
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"
Longitude: " + position.coords.longitude;
}
The weather outside is:
Oops.. there is no temperature available for your location right now.
我的JavaScript代码:
$(document).ready(function(){
$.getJSON( "http://api.openweathermap.org/data/2.5/weather?q=Eindhoven&appid=9334f947893792dcb9b2e2c05ae23eb0", function( data ) {
$('.weather').html(Math.round(data.main.temp-273)+ ' degrees Celcius');
});
});
我得到了埃因霍温市的天气工作,但我希望能够将其调整到纬度和经度.
有人可以为我修复我的代码吗?帮助我?
我知道它与此链接有关:api.openweathermap.org/data/2.5/weather?lat={lat}\u0026amp;lon={lon}但我不知道如何实现我自己的fount纬度和经度在里面…