Showing
1 changed file
with
41 additions
and
1 deletions
... | @@ -31,6 +31,12 @@ export default class Home extends Component { | ... | @@ -31,6 +31,12 @@ export default class Home extends Component { |
31 | region: "은평구청", | 31 | region: "은평구청", |
32 | curAirCondition: null, | 32 | curAirCondition: null, |
33 | routeInformation: null, | 33 | routeInformation: null, |
34 | + temperature: null, | ||
35 | + humidity: null, | ||
36 | + weather: null, | ||
37 | + icon: null, | ||
38 | + wind: null, | ||
39 | + cloud: null, | ||
34 | }; | 40 | }; |
35 | } | 41 | } |
36 | 42 | ||
... | @@ -303,6 +309,35 @@ export default class Home extends Component { | ... | @@ -303,6 +309,35 @@ export default class Home extends Component { |
303 | .finally(function () { | 309 | .finally(function () { |
304 | // always executed | 310 | // always executed |
305 | }); | 311 | }); |
312 | + | ||
313 | + API.get("airCondition/weather", { | ||
314 | + params: { | ||
315 | + latitude: position["Ha"], | ||
316 | + longitude: position["Ga"], | ||
317 | + }, | ||
318 | + }) | ||
319 | + .then((response) => { | ||
320 | + let resp = response["data"]; | ||
321 | + console.log(resp); | ||
322 | + console.log("현재온도 : " + (resp.main.temp - 273.15)); | ||
323 | + console.log("현재습도 : " + resp.main.humidity); | ||
324 | + console.log("날씨 : " + resp.weather[0].main); | ||
325 | + console.log("상세날씨설명 : " + resp.weather[0].description); | ||
326 | + console.log("날씨 이미지 : " + resp.weather[0].icon); | ||
327 | + console.log("바람 : " + resp.wind.speed); | ||
328 | + console.log("구름 : " + resp.clouds.all + "%"); | ||
329 | + this.setState({ | ||
330 | + temperature: (resp.main.temp - 273.15).toFixed(3), | ||
331 | + humidity: resp.main.humidity, | ||
332 | + weather: resp.weather[0].main, | ||
333 | + icon: resp.weather[0].icon, | ||
334 | + wind: resp.wind.speed, | ||
335 | + cloud: resp.clouds.all + "%", | ||
336 | + }); | ||
337 | + }) | ||
338 | + .catch(function (error) { | ||
339 | + console.log(error); | ||
340 | + }); | ||
306 | }; | 341 | }; |
307 | let setDepart = document.createElement("Button"); | 342 | let setDepart = document.createElement("Button"); |
308 | setDepart.innerHTML = "출발지로 설정하기"; | 343 | setDepart.innerHTML = "출발지로 설정하기"; |
... | @@ -400,7 +435,12 @@ export default class Home extends Component { | ... | @@ -400,7 +435,12 @@ export default class Home extends Component { |
400 | <br /> 미세먼지 등급 <br /> {pm10Image} <br /> | 435 | <br /> 미세먼지 등급 <br /> {pm10Image} <br /> |
401 | 미세먼지 지수 : {this.state.curAirCondition.pm10Value} <br /> | 436 | 미세먼지 지수 : {this.state.curAirCondition.pm10Value} <br /> |
402 | 초미세먼지 등급 <br /> {pm25Image} <br /> | 437 | 초미세먼지 등급 <br /> {pm25Image} <br /> |
403 | - 초미세먼지 지수 : {this.state.curAirCondition.pm25Value} <br />{" "} | 438 | + 초미세먼지 지수 : {this.state.curAirCondition.pm25Value} <br /> |
439 | + 현재 온도 : {this.state.temperature} ℃ <br /> | ||
440 | + 현재 습도 : {this.state.humidity} <br /> | ||
441 | + 날씨 : {this.state.weather} <br /> | ||
442 | + 바람 : {this.state.wind} <br /> | ||
443 | + 구름 : {this.state.cloud} <br />{" "} | ||
404 | </h5> | 444 | </h5> |
405 | ); | 445 | ); |
406 | } | 446 | } | ... | ... |
-
Please register or login to post a comment