Showing
2 changed files
with
126 additions
and
2 deletions
... | @@ -58,7 +58,7 @@ const getPosition = (lat, lon) => { | ... | @@ -58,7 +58,7 @@ const getPosition = (lat, lon) => { |
58 | console.log(error.response); | 58 | console.log(error.response); |
59 | }); | 59 | }); |
60 | }; | 60 | }; |
61 | -/* GET airCondition listing. */ | 61 | +/* GET route airCondition listing. */ |
62 | router.get("/route", async function (req, res, next) { | 62 | router.get("/route", async function (req, res, next) { |
63 | console.log("출발지:", req.query.departure); | 63 | console.log("출발지:", req.query.departure); |
64 | console.log("도착지:", req.query.arrival); | 64 | console.log("도착지:", req.query.arrival); | ... | ... |
... | @@ -11,7 +11,9 @@ import good from "./gradeIcon/smile.png"; | ... | @@ -11,7 +11,9 @@ import good from "./gradeIcon/smile.png"; |
11 | import bad from "./gradeIcon/angry.png"; | 11 | import bad from "./gradeIcon/angry.png"; |
12 | import veryBad from "./gradeIcon/devil.png"; | 12 | import veryBad from "./gradeIcon/devil.png"; |
13 | import next from "./gradeIcon/next.png"; | 13 | import next from "./gradeIcon/next.png"; |
14 | - | 14 | +import start from "./gradeIcon/start.png"; |
15 | +import finish from "./gradeIcon/finish.png"; | ||
16 | +import loading from "./gradeIcon/loading.gif"; | ||
15 | /* global kakao */ | 17 | /* global kakao */ |
16 | 18 | ||
17 | export default class Home extends Component { | 19 | export default class Home extends Component { |
... | @@ -403,6 +405,128 @@ export default class Home extends Component { | ... | @@ -403,6 +405,128 @@ export default class Home extends Component { |
403 | ); | 405 | ); |
404 | } | 406 | } |
405 | let routeAirCondition = null; | 407 | let routeAirCondition = null; |
408 | + let tempRouteAirCondition = []; | ||
409 | + if (this.state.buttonClicked != null) { | ||
410 | + routeAirCondition = <img src={loading} width="300px" heigth="300px" />; | ||
411 | + } | ||
412 | + if (this.state.routeInformation != null) { | ||
413 | + for (let i = 0; i < this.state.routeInformation.length - 1; i++) { | ||
414 | + tempRouteAirCondition.push(this.state.routeInformation[i]); | ||
415 | + } | ||
416 | + let pm10ImageArray = new Array(); | ||
417 | + let pm25ImageArray = new Array(); | ||
418 | + for (let i = 0; i < this.state.routeInformation.length; i++) { | ||
419 | + let pm10Image = null; | ||
420 | + let pm25Image = null; | ||
421 | + switch (this.state.routeInformation[i]["airCondition"].pm10Grade) { | ||
422 | + case "1": | ||
423 | + pm10Image = <img src={veryGood} width="50px" heigth="100px" />; | ||
424 | + break; | ||
425 | + case "2": | ||
426 | + pm10Image = <img src={good} width="50px" heigth="100px" />; | ||
427 | + break; | ||
428 | + case "3": | ||
429 | + pm10Image = <img src={bad} width="50px" heigth="100px" />; | ||
430 | + break; | ||
431 | + case "4": | ||
432 | + pm10Image = <img src={veryBad} width="50px" heigth="100px" />; | ||
433 | + break; | ||
434 | + default: | ||
435 | + pm10Image = null; | ||
436 | + } | ||
437 | + switch (this.state.routeInformation[i]["airCondition"].pm25Grade) { | ||
438 | + case "1": | ||
439 | + pm25Image = <img src={veryGood} width="50px" heigth="100px" />; | ||
440 | + break; | ||
441 | + case "2": | ||
442 | + pm25Image = <img src={good} width="50px" heigth="100px" />; | ||
443 | + break; | ||
444 | + case "3": | ||
445 | + pm25Image = <img src={bad} width="50px" heigth="100px" />; | ||
446 | + break; | ||
447 | + case "4": | ||
448 | + pm25Image = <img src={veryBad} width="50px" heigth="100px" />; | ||
449 | + break; | ||
450 | + default: | ||
451 | + pm25Image = null; | ||
452 | + } | ||
453 | + pm10ImageArray[i] = pm10Image; | ||
454 | + pm25ImageArray[i] = pm25Image; | ||
455 | + } | ||
456 | + routeAirCondition = ( | ||
457 | + <table> | ||
458 | + <thead> | ||
459 | + <tr> | ||
460 | + <th> | ||
461 | + <br /> | ||
462 | + 경로별 미세먼지 정보 | ||
463 | + </th> | ||
464 | + </tr> | ||
465 | + </thead> | ||
466 | + <tbody> | ||
467 | + <tr> | ||
468 | + <td> | ||
469 | + <img src={start} width="50px" heigth="30px" /> <br /> | ||
470 | + <h6> | ||
471 | + {this.state.departureTitle} <br /> 미세먼지 등급 | ||
472 | + <br /> | ||
473 | + {pm10ImageArray[this.state.routeInformation.length - 1]} | ||
474 | + <br /> | ||
475 | + 미세먼지 지수 :{" "} | ||
476 | + { | ||
477 | + this.state.routeInformation[ | ||
478 | + this.state.routeInformation.length - 1 | ||
479 | + ]["airCondition"].pm10Value | ||
480 | + } | ||
481 | + <br /> | ||
482 | + </h6> | ||
483 | + </td> | ||
484 | + {tempRouteAirCondition.map((listValue, index) => { | ||
485 | + if (index != tempRouteAirCondition.length - 1) { | ||
486 | + return ( | ||
487 | + <td key={index}> | ||
488 | + <img src={next} width="40px" heigth="25px" /> | ||
489 | + <h6> | ||
490 | + {listValue.instruction} | ||
491 | + <br /> | ||
492 | + 소요시간 : {listValue.duration} | ||
493 | + <br /> | ||
494 | + 미세먼지 등급 | ||
495 | + <br /> | ||
496 | + {pm10ImageArray[index]} | ||
497 | + <br /> | ||
498 | + 미세먼지 지수 : <br /> | ||
499 | + {listValue.airCondition.pm10Value} | ||
500 | + <br /> | ||
501 | + </h6> | ||
502 | + </td> | ||
503 | + ); | ||
504 | + } else { | ||
505 | + return ( | ||
506 | + <td key={index}> | ||
507 | + <img src={finish} width="50px" heigth="30px" /> | ||
508 | + <br /> | ||
509 | + <h6> | ||
510 | + {listValue.instruction} | ||
511 | + <br /> | ||
512 | + 소요시간 : {listValue.duration} | ||
513 | + <br /> | ||
514 | + 미세먼지 등급 | ||
515 | + <br /> | ||
516 | + {pm10ImageArray[index]} | ||
517 | + <br /> | ||
518 | + 미세먼지 지수 : {listValue.airCondition.pm10Value} | ||
519 | + <br /> | ||
520 | + </h6> | ||
521 | + </td> | ||
522 | + ); | ||
523 | + } | ||
524 | + })} | ||
525 | + </tr> | ||
526 | + </tbody> | ||
527 | + </table> | ||
528 | + ); | ||
529 | + } | ||
406 | 530 | ||
407 | return ( | 531 | return ( |
408 | <section id="home"> | 532 | <section id="home"> | ... | ... |
-
Please register or login to post a comment