From the google maps API documentation I have got this working:
var flightPlanCoordinates = [
new google.maps.LatLng(37.772323, -122.214897),
new google.maps.LatLng(21.291982, -157.821856),
new google.maps.LatLng(-18.142599, 178.431),
new google.maps.LatLng(-27.46758, 153.027892)
];
what ive tried to do is replicate this piece of code with my own loop so I can use previously stored co-ords, like so:
var output;
$.getJSON('DisplayMap.php', function(data) {
var output = "[ ";
for (var i in data.b) {
output+= "new google.maps.LatLng" + "(" + data.b[i].Ya + ", " + data.b[i].Za + ")," + " ";
}
output+= "]";
document.getElementById("placeholder").innerHTML=output;
alert(output);
});
output+= "]";
Ive checked the output and it looks exactly as I want it to. however, when I substitute it in like this is doesnt work:
var flightPlanCoordinates = output;