| Server IP : 69.72.244.102 / Your IP : 216.73.216.164 Web Server : LiteSpeed System : Linux s3434.fra1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64 User : konzalta ( 1271) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/konzalta/gikuyu.online/incidents/ |
Upload File : |
<!DOCTYPE html>
<html>
<head>
<title>Google Maps Marker with MySQL Data</title>
<style>
#map {
height: 800px;
width: 100%;
}
#myModal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
</style>
</head>
<body>
<div id="map"></div>
<!-- Modal -->
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<div id="modalContent"></div>
</div>
</div>
<script>
// Initialize and add the map
function initMap() {
// The location of the marker
var markerLocation = {lat: -1.27696640, lng: 36.89365360};
// The map, centered at marker location
var map = new google.maps.Map(
document.getElementById('map'), {zoom: 15, center: markerLocation});
// The marker, positioned at marker location
var marker = new google.maps.Marker({position: markerLocation, map: map});
// Add click event listener to the marker
marker.addListener('click', function() {
// Fetch data from MySQL using AJAX
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// Display fetched data in modal
document.getElementById("modalContent").innerHTML = this.responseText;
document.getElementById("myModal").style.display = "block";
}
};
xmlhttp.open("GET", "get_marker_info.php", true);
xmlhttp.send();
});
// Close modal when close button is clicked
document.querySelector('.close').addEventListener('click', function() {
document.getElementById("myModal").style.display = "none";
});
}
</script>
<script async
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBYHXHuzyyQgLKU7NXczF1XLPaxeDmLJ3o&loading=async&callback=initMap">
</script>
</body>
</html>