So my particular problem is as follows - I have a PHP page which loops through a list of coordinates and displays them on my page.
As well as this I want to display them on a map.
I have come up with two methods of doing this, both of which work - I was curious as to which is best, and why?
My understanding is that by placing my javascript within the below, my javascript does not execute until my page is loaded. It is for this reason that both methods work.
$(document).ready(function()
{
});
The first one is hidden form fields. I can pass my longitude and latitude and get them in my javascript file using jQuery.
The second one is to simply use
<script type='text/javascript'>
var myarray = <?php echo JSON_encode($array); ?>;
</script>
within my PHP script and then access/loop through it in my Javascript file in a similar way i loop through it in my PHP file.
for (var i=0, tot=myarray.length; i < tot; i++)
{//plot points}
Thanks