Great, the problem I'm having is that the maps dissapear, and I have to reaload the page , sometimes 4 to 5 times and then works.
Chrome says that I've 1 error and 1 possible improvement.
I know that the map is shaded because of the Credit card payment, but I think that's not the problem.
The improvement is about Quirks mode, I tried modifying the htacces on the server to include php so that i can name the DOCTYPE as HTML but, it didn't work.
The code from "index.php" :
<?php
session_start();
include("connection.php");
include("functions.php");
$user_data = check_login($con);
?>
<?php
include 'getstate.php';
?>
<html>
<head>
<meta name="viewport" content width="devide-width, initial-scale=1.0">
<title>Sistema de gestión de balizas</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="split left">
<div class="left">
<h1 style="text-align:center"> Sistema de gestión de balizas</h1>
<hr class="solid">
<br>
<form action="save.php" method="post">
Identificador: <input type="text" name="identificador"><br>
Intensidad: <input type="text" name="green"><br>
Tiempo prendida (0 - 5 ): <input type="text" name="yellow"><br>
Tiempo apagada (0 - 5): <input type="text" name="blue"><br>
<input type="submit" value="Enviar">
</form>
<hr class="solid">
<p> Identificador :
<?php
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT State FROM ledStatus WHERE Color= 'identificador'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row["State"];
if ($row["State"]==0){
echo " " ." - Baliza principal";
}
else {
echo " " ." - Baliza auxiliar";
}
}
}
$conn->close();
?>
<hr class="solid">
<p> Voltaje de la batería de la baliza :
<?php
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT State FROM ledStatus WHERE Color= 'identificador'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
//echo $row["State"];
if ($row["State"]==0){
$sql = "SELECT voltaje1 FROM tbl_gps ORDER BY id DESC LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row["voltaje1"];
}
}
//echo " " ." - Baliza principal";
}
else {
$sql = "SELECT voltaje2 FROM tbl_gps ORDER BY id DESC LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row["voltaje2"];
}
}
//echo " " ." - Baliza auxiliar";
}
}
}
$conn->close();
echo " "
?>
V
<hr class="solid">
<p> Cadencia:
<?php
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT State FROM ledStatus WHERE Color= 'yellow'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
// echo $row["State"];
if ($row["State"]==0){
echo " " ." 0 ms Encendida ";
}
else if($row["State"]==1) {
echo " " ." 100 ms Encendida ";
}
else if($row["State"]==2) {
echo " " ." 200 ms Encendida ";
}
else if($row["State"]==3) {
echo " " ." 500 ms Encendida ";
}
else if($row["State"]==4) {
echo " " ." 800 ms Encendida ";
}
else if($row["State"]==5) {
echo " " ." 1000 ms Encendida ";
}
}
}
$sql = "SELECT State FROM ledStatus WHERE Color= 'blue'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
//echo $row["State"];
if ($row["State"]==0){
echo " " ." - 0 ms Apagada ";
}
else if($row["State"]==1) {
echo " " ." - 100 ms Apagada ";
}
else if($row["State"]==2) {
echo " " ." - 200 ms Apagada ";
}
else if($row["State"]==3) {
echo " " ." - 500 ms Apagada ";
}
else if($row["State"]==4) {
echo " " ." - 800 ms Apagada ";
}
else if($row["State"]==5) {
echo " " ." - 1000 ms Apagada ";
}
}
}
$conn->close();
?>
<hr class="solid">
<p> Intensidad (Lm):
<?php
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT State FROM ledStatus WHERE Color= 'green'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row["State"];
if ($row["State"]==0){
echo " " ." - 0 mcd";
}
else if ($row["State"]==1){
echo " " ." - 1000 mcd";
}
else if ($row["State"]==2){
echo " " ." - 2000 mcd";
}
else if ($row["State"]==3){
echo " " ." - 3000 mcd";
}
else if ($row["State"]==4){
echo " " ." - 4000 mcd";
}
else if ($row["State"]==5){
echo " " ." - 5000 mcd";
}
}
}
$conn->close();
?>
<hr class="solid">
<p> Estado de la baliza:
<?php
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT State FROM ledStatus WHERE Color= 'green'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row["State"];
if ($row["State"]==0){
echo " " ." - La baliza esta apagada";
}
else {
echo " " ." - La baliza esta prendida";
}
}
}
$conn->close();
?>
<hr class="solid">
<p> Latitud:
<?php
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT lat FROM tbl_gps ORDER BY id DESC LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row["lat"];
}
}
$conn->close();
?>
<hr class="solid">
<p> Longitud:
<?php
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT lng FROM tbl_gps ORDER BY id DESC LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row["lng"];
}
}
$conn->close();
?>
<hr class="solid">
<p> Estado de conexión (Red Celular o LoRa):
<?php
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT State FROM ledStatus WHERE Color= 'identificador'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row["State"];
if ($row["State"]==0){
echo " " ." - Red Celular";
}
else {
echo " " ." - LoRa";
}
}
}
$conn->close();
?>
<hr class="solid">
<p> Usuario registrado como:<?php echo $user_data['user_name']; ?> </p>
<p>Para salir : <a href="logout.php">Logout</a> </p>
<hr class="solid">
</div>
</div>
<div class="split right">
<div class="end">
<?php
require 'config.php';
$sql = "SELECT * FROM tbl_gps WHERE 1";
$result = $db->query($sql);
if (!$result) {
{ echo "Error: " . $sql . "<br>" . $db->error; }
}
$rows = $result -> fetch_all(MYSQLI_ASSOC);
?>
<html>
<head>
<h1 style="text-align:center"> Ubicación de las balizas</h1>
</head>
<style>
/*
* Optional: Makes the sample page fill the window.
*/
html,
body {
height: 100%;
margin: 0;
padding: 0;
font-family: Arial;
}
/*
* Always set the map height explicitly to define the size of the div element
* that contains the map.
* Margin(vertical,horizontal)
* max-width(el ancho del mapa)
* min-height (el alto minimo del mapa)
*/
#map-layer {
height: 60%;
margin: 40px 40px;
max-width: 600px;
min-height: 100;
}
</style>
<body>
<div id="map-layer"></div>
<script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBKXiCf4p90xhFm-MugEJVk3_FMdGTrajA&callback=initMap"
async defer></script>
<script>
var map;
function initMap() {
var mapLayer = document.getElementById("map-layer");
var centerCoordinates = new google.maps.LatLng(48.8685,2.3045);
var defaultOptions = { center: centerCoordinates, zoom: 10 }
map = new google.maps.Map(mapLayer, defaultOptions);
<?php foreach($rows as $location){ ?>
var location = new google.maps.LatLng(<?php echo $location['lat']; ?>, <?php echo $location['lng']; ?>);
var marker = new google.maps.Marker({
position: location,
map: map
});
<?php } ?>
}
</script>
</body>
</html>
</div>
</div>
</div>
</div>
</body>
</html>
Here is the code from "style.css" :
*
{
margin :1;
padding :0;
box-sizing:border-box;
font-family:'Poppins', sans-serif ;
margin-bottom:20px;
}
.container {
width:100%;
height:100vh;
display:flex;
align-items:flex-end;
justify-content:flex-end;
flex-direction:column;
}
h1{
color:#333;
margin-bottom:20px;
align-items:center;
justify-content:center;
}
iframe {
width:120%;
height:400px;
}
/* Split the screen in half */
.split {
height: 100%;
width: 50%;
position: fixed;
z-index: 1;
top: 0;
overflow-x: hidden;
padding-top: 20px;
}
/* Control the left side */
.left {
left: 0;
background-color: lightgreen;
}
/* Control the right side */
.right {
right: 0;
background-color: blue;
}
/* If you want the content centered horizontally and vertically */
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
text-align: center;
}
/* Style the image inside the centered container, if needed */
.centered img {
width: 150px;
border-radius: 50%;
}
/* Solid border */
.solid {
border-top: 3px solid #bbb;
}
/*
* Always set the map height explicitly to define the size of the div element
* that contains the map.
*/
#map {
height: 100%;
}
/*
* Optional: Makes the sample page fill the window.
*/
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
File "htaccess" :
# HTID:21410327: DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES BELOW
php_value display_errors 1
# DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES ABOVE HTID:21410327:
AddType application/x-httpd-php .html
One thing I noticed is that if I clear the History/Cookies it works fine.
Thank you for your help.