I have an MySQL database with thousands of entries with coordinates.
An entry looks like this: id, dt, img, long, lat
For now, I list the top 20 from mysql. But how do I get the 20 entries most near a given point? The given point is "center" in the code below.
Images
<script type="text/javascript">
$(document).ready(function(){
var myMarkers = {"markers": [
<?php
$query="SELECT id, dt, img, long, lat FROM places LIMIT 20";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$row = mysql_fetch_array($result);
$pl_id = $row[0];
$pl_dt = $row[1];
$pl_img = $row[2];
$pl_longitud = $row[3];
$pl_latitud = $row[4];
$pres = "Text is coming.";
?>
{"latitude": "<?php echo $pl_latitud ?>", "longitude":"<?php echo $pl_longitud ?>", "icon":"<?php echo $pl_img ?>", "baloon_text":"<?php echo $pres ?>"},
<?php
$i++;
}
?>
]};
$("#map").mapmarker({ zoom : 10,
center : '<?php echo $pl_latitud; ?>, <?php echo $pl_longitud; ?>',
markers : myMarkers
});
});
</script>