1 | <?php |
||
2 | namespace Anax\View; |
||
3 | |||
4 | ?> |
||
5 | <h1>Senaste Uppmätta Dagar</h1> |
||
6 | |||
7 | <?php if ($data[0]["count"] == 0) :?> |
||
8 | <p>Var vänlig skriv in en giltil stad.</p> |
||
9 | <?php endif; ?> |
||
10 | <?php if ($data[0]["count"] != 0) : |
||
11 | echo "<table id='weather-table'> |
||
12 | |||
13 | <tr> |
||
14 | |||
15 | <th>Days Since</th> |
||
16 | |||
17 | <th>Main Weather</th> |
||
18 | |||
19 | <th>Temperature</th> |
||
20 | |||
21 | <th>What it felt like</th> |
||
22 | |||
23 | <th>Icon</th> |
||
24 | |||
25 | </tr>"; |
||
26 | |||
27 | ?> |
||
28 | |||
29 | <?php for ($x = 0; $x < count($data[0]["list"]); $x++) { |
||
30 | echo "<tr>"; |
||
31 | echo "<td>" .json_encode($x + 1). "</td>"; |
||
32 | echo "<td>" . trim(json_encode($data[0]["list"][$x]["weather"][0]["main"]), '"') . "</td>"; |
||
33 | echo "<td>" . round(json_encode($data[0]["list"][$x]["main"]["temp"]-273.15), 1). " C°" . "</td>"; |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
34 | echo "<td>" . round(json_encode($data[0]["list"][$x]["main"]["feels_like"]-273.15), 1) . "</td>"; |
||
35 | echo "<td><img src=\"http://openweathermap.org/img/wn/" . trim(json_encode($data[0]["list"][$x]["weather"][0]["icon"]), '"') . "@2x.png\"></td>"; |
||
36 | } |
||
37 | echo "</tr>"; |
||
38 | echo "</table>"; |
||
39 | ?> |
||
40 | |||
41 | |||
42 | |||
43 | <h1>Karta</h1> |
||
44 | <?php |
||
45 | |||
46 | $long = 0; |
||
47 | $lat = 0; |
||
48 | |||
49 | foreach ($data as $key => $row) : |
||
50 | $long = trim(json_encode($data[0]["list"][0]["coord"]["lon"]), '"'); |
||
51 | $lat = trim(json_encode($data[0]["list"][0]["coord"]["lat"]), '"'); |
||
52 | endforeach;?> |
||
53 | |||
54 | <p style="display: none;" id="longitude"><?= $long ?></p> |
||
55 | <p style="display: none;" id="latitude"><?= $lat ?></p> |
||
56 | |||
57 | <p style="display: none;" id="longitude"><?= $long ?></p> |
||
58 | <p style="display: none;" id="latitude"><?= $lat ?></p> |
||
59 | |||
60 | <div style="height: 400px;" id="map"></div> |
||
61 | |||
62 | <link rel="stylesheet" type="text/css" href="https://unpkg.com/[email protected]/dist/leaflet.css"> |
||
63 | <script src='https://unpkg.com/[email protected]/dist/leaflet.js'></script> |
||
64 | <script type="text/javascript"> |
||
65 | |||
66 | var longitude = document.getElementById('longitude').innerText; |
||
67 | var latitude = document.getElementById('latitude').innerText; |
||
68 | |||
69 | var map = L.map('map').setView([latitude, longitude], 11); |
||
70 | |||
71 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
||
72 | attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' |
||
73 | }).addTo(map); |
||
74 | |||
75 | L.marker([latitude, longitude]).addTo(map) |
||
76 | .openPopup(); |
||
77 | </script> |
||
78 | </div> |
||
79 | |||
80 | <?php endif; ?> |
||
81 |