<script>
var planes = [['7C6Buh',37.7353,-122.3732]
<?php
$DB = mysqli_connect('localhost','username','password','abc'); $Q = "SELECT length, width FROM abcstat WHERE siteid='xyz'"; $R = mysqli_query($DB,$Q); //start loop //while or foreach while($row = mysqli_fetch_assoc($R)){ echo ",['7C6Buh',{$row['length']},{$row['width']}]\r\n"; } ?> ];
var map = L.map('map').setView([19.426216, 15.7166481], 1); mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>'; L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© ' + mapLink + ' Contributors', maxZoom: 8, }).addTo(map);
for (var i = 0; i < planes.length; i++) { marker = new L.marker([planes[i][1],planes[i][2]]) .bindPopup(planes[i][0]) .addTo(map); } </script>
<div id="map" style="width: 650px; height: 400px"></div>
<script>
var map = L.map('map').setView([19.426216, 15.7166481], 1);
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href=\"http://openstreetmap.org\">OpenStreetMap</a> Contributors', maxZoom: 8 }).addTo(map);
window.addEventListener("load", function() { updatePoints(); });
function getMarkers(planes) {
for (var i = 0; i < planes.length; i++) {
marker = new L.marker([planes[i][1],planes[i][2]]).bindPopup(planes[i][0]).addTo(map);
}
}
function updatePoints() {
$.post("getplanes.php").done(function(planes){ getMarkers(planes); }});
setTimeout(function(){ updatePoints(); }, 10000);
}
</script>