Hey,
I'm using JavaScript with Google Maps, but i'm having trouble inserting some PHP in here.
For each row in the routes table I want to create a path (Google Maps) and add that to an array.
Unfortunately Im having massive issues, which is simple I presume as It doesn't even reach the alert() message.
CODE:
function loadRoutes() {
<?php
$r = mysql_query ("SELECT * FROM routes");
while($row = mysql_fetch_assoc($r))
{
echo('
var coordinates = '.$row["coordinates"].'
coordinates = coordinates.replace(/[(]/g, "");
coordinates = coordinates.replace(/[)],/g, "&");
var temp = [];
var temp2 = [];
temp = coordinates.split("&");
temp2 = temp[0].split(",");
var latlng = new google.maps.LatLng(parseFloat(temp2[0]), parseFloat(temp2[1]));
path.push(latlng);
// -1 gets rid of the last string which is empty space
alert("Starting For...");
for (var i = 1; i < temp.length-1; i++)
{
temp2 = temp[i].split(",");
var latlng = new google.maps.LatLng(parseFloat(temp2[0]), parseFloat(temp2[1]));
path.push(latlng);
}
pathArray['.$row["id"].'] = path;
');
};
?>
}
Thanks Guys,
Rick