-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
84 lines (65 loc) · 2.24 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>RD2T</title>
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="mapFunctions.js"></script>
</head>
<body>
<?php
function debugFunction()
{
echo 'I just ran a php function';
echo "<h6>Name " . $_GET["file"] . "</h6>";
}
function initMapJS($markers)
{
$jsMarkers = json_encode($markers);
?>
<script type="text/javascript" src="mapFunctions.js">
var arrayJS=<?php echo json_encode($markers);?>;
console.log(arrayJS[0]);
</script>
<?php
}
/*{
$jsMarkers = json_encode($markers);
echo '<script type="text/javascript" src="mapFunctions.js">';
echo 'var jsMarkers ='.$jsMarkers.';';
echo 'initMap(jsMarkers);';
echo '</script>';
}*/
function loadCSVdata()
{
$data = file_get_contents('./' . $_GET["file"] . '/' . $_GET["file"] . '.csv');
$lines = explode("\n\n", $data);
foreach ($lines as $key => $value) {
if ($key > 0 && strlen($value) > 10) { // skip csv header row and blank rows
$line = explode(",", $value); // Separador ,
// Nombre de estación, latitud, longitud, Nivel, Variable, Previsión
$markers[$key] = trim($line[1]) . ',' . trim($line[2]) . ',' . trim($line[3]) . ',' . trim($line[4]) . ',' . trim($line[5]) . ',' . trim($line[6]);
}
}
$counter = 0;
initMapJS($markers);
}
if (isset($_GET['loadData'])) {
loadCSVdata();
}
?>
<section id="menuSection" class="menuSection">
<a id="tituloMenu" class="menuItem">Pronósticos</a>
<a href="index.php?loadData=true&file=Roadcast_2018-04-01" class="menuItem">Roadcast_2018-04-01</a>
<a href="index.php?loadData=true&file=Roadcast_2018-04-01" class="menuItem">Roadcast_2018-04-01</a>
<a href="index.php?loadData=true&file=Roadcast_2018-04-01" class="menuItem">Roadcast_2018-04-01</a>
<a href="index.php?loadData=true&file=Roadcast_2018-04-01" class="menuItem">Roadcast_2018-04-01</a>
</section>
<section id="map" class="map"/>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD_ohx4ay8JsbMcpbCDEcaxEUp36gMrUiQ"></script>
<script>
google.maps.event.addDomListener(window, 'load', initMap);
</script>
</body>
</html>