What I'm trying to do is to populate routes using the Google Maps API. I've written a working function that takes in any given array of lat/long values, I have a big database coordinates and I want to populate the map with a selection.
How can I get the data into JavaScript? So far I've got a button on the site and when pressed it runs a query that echoes what I need into some new page in JSON format:
$con = mysqli_connect("localhost","root","password","database");
$return_arr = array(); $result = mysqli_query($con,"SELECT * FROM
Flight_Data WHERE `DepDateTimeUTC` LIKE '%10/1/13%'");
while ($row = mysqli_fetch_array($result)) {
$row_array['ID'] = $row['ID'];
$row_array['OriginLat'] = $row['OriginLat'];
$row_array['OriginLong'] = $row['OriginLong'];
$row_array['DestinLat'] = $row['DestinLat'];
$row_array['DestinLong'] = $row['DestinLong'];
array_push($return_arr,$row_array); }
$jsonarray = json_encode($return_arr); echo $jsonarray;
This is a sample of the data:
[
{
"ID":"1",
"OriginLat":"48.6899",
"OriginLong":"9.2220",
"DestinLat":"37.014425",
"DestinLong":"-7.965910"
},
....
]
So I need to parse that into an array and be able to access each of the values like masterArray[1][4] etc.
So I'm stuck, the JavaScript is in a separate file, and so is the PHP script, I can put it in the same HTML page but I still don't know how to get it.