Google Map Codes
Google Map Codes
Google Map Codes
php
/* Database connection settings */
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'location_db';
$mysqli = new mysqli($host,$user,$pass,$db) or die($mysqli->error);
$coordinates = array();
$latitudes = array();
$longitudes = array();
$latitudes[] = $row['locationLatitude'];
$longitudes[] = $row['locationLongitude'];
$coordinates[] = 'new google.maps.LatLng(' .
$row['locationLatitude'] .','. $row['locationLongitude'] .'),';
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Map | View</title>
</head>
<body>
<nav>
<ul>
<li class="active"><a href="#"><img
src="img/map.png"></a></li>
<li><a href="#"><img src="img/logout.png"></a></li>
</ul>
</nav>
<div class="outer-scontainer">
<div class="row">
<form class="form-horizontal" action="" method="post"
name="frmCSVImport" id="frmCSVImport" enctype="multipart/form-data">
<div class="form-area">
<button type="submit" id="submit" name="import"
class="btn-submit">RELOAD DATA</button><br />
</div>
</form>
</div>
<div id="map" style="width: 100%; height: 80vh;"></div>
<script>
function initMap() {
var mapOptions = {
zoom: 18,
center: {<?php echo'lat:'. $latitudes[0] .', lng:'.
$longitudes[0] ;?>}, //{lat: --- , lng: ....}
mapTypeId: google.maps.MapTypeId.SATELITE
};
var RouteCoordinates = [
<?php
$i = 0;
while ($i < count($coordinates)) {
echo $coordinates[$i];
$i++;
}
?>
];
mark = 'img/mark.png';
flag = 'img/flag.png';
RoutePath.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
</html>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "";
if (mysqli_query($conn, $sql)) {
echo "Database created successfully<br>";
} else {
echo "Error creating database: " . mysqli_error($conn) . "<br>";
}
$dbname = 'location_db';
mysqli_select_db ( $conn , $dbname);
if (!$conn) {
die("select db connection failed: " . mysqli_connect_error());
}
if(mysqli_query($conn, $sql)){
echo "Table location created successfully<br>";
} else {
echo "Error creating location table: " . mysqli_error($conn). "<br>";
}
mysqli_close($conn);
?>
body{
font-family: Arial;
margin: 5px 100px 10px 100px;
padding: 0;
color: white;
text-align: center;
background: #555; /*#555652;*/
}
nav{
margin: 0;
padding:0;
margin-bottom: 10px;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #222;
}
li {
margin: 0;
padding:0;
float: left;
}
li a{
display: block;
color: white;
text-align: center;
padding-top: 10px;
padding-bottom: 10px;
padding-right: 40px;
padding-left: 40px;
border-right: 1px solid #555652;
text-decoration: none;
}
li a img{
width: 30px;
height: 30px;
}
li a:hover {
background-color: #555652;
}
.active{
background-color: #DD4F43;
}
.form-area{
float: right;
display: table-column;
margin-bottom: 10px;
color: white;
}
.btn-submit {
outline: 0;
background: #F4BA0F;
width: 120px;
border: 0;
padding: 8px;
color: white;
font-size: 12px;
cursor: pointer;
}
#userTable{
background: #222;
}
.outer-scontainer {
color: #E8E9EB;
background: #333;
border: #555652 1px solid;
padding: 10px;
}
.outer-scontainer table {
/*border-collapse: collapse;*/
width: 100%;
}
.outer-scontainer th {
border: 1px solid #555652;
padding: 5px;
text-align: center;
}
.outer-scontainer td {
border: 1px solid #555652;
padding: 5px;
text-align: center;
}