2

openweathermap API を使用してユーザーの都市と地域の気温を表示するページを作成しようとしていますが、残念ながら JSON API を処理していないようで、何もしていません。私のコードは私が知る限り問題ないので、何が問題なのかわかりません。
jsfiddle リンクと javascript コードは次のとおりです:
https://jsfiddle.net/qo2h1L9e/2/

 $(document).ready(function() {
  var data;
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var lat = position.coords.latitude;
      var lon = position.coords.longitude;
      console.log(lat);
      console.log(lon);
      console.log("api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&APPID=4907e373098f091c293b36b92d8f0886");
      $.getJSON("api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&APPID=4907e373098f091c293b36b92d8f0886", function(json) {
        data = json;
        console.log(data.name);
        $("#city").text(data.name);
      });
    });
  }
});
4

2 に答える 2