PHP:
if (@mysql_num_rows($resultados) > 0){
while ($linha = mysql_fetch_array($sql))
$retorno = array($linha);
// print_r(json_encode($retorno));
echo json_encode($retorno);
}
How to manipulate, ie break this json with ajax so that you can use your data separately?
The function looks like this: That's how I tried, but it did not work ... Look how I did it:
function marcacao(){
$.ajax({
type: "get",
url: $server+"/conecta.php",
data: "acao=marcacao",
success: function(data) {
var resultado = JSON.parse(data);
console.log(resultado);
for(var i = 0; i<=data.length; i++){
$Jlati = resultado.employees[1];
$Jlng = resultado.employees[2];
var map = new google.maps.Map(
document.getElementById("map"),
{
center : new google.maps.LatLng($Jlati[i], $Jlng[i]),
zoom : 5,
mapTypeId : google.maps.MapTypeId.ROADMAP
}
);
var image = 'www/images/ray001.png';
var marker = new google.maps.Marker(
{
title : "VOCÊ ESTÁ AQUI: "+$Jlati[i]+", "+$Jlng[i],
position : new google.maps.LatLng($Jlati[i], $Jlng[i]),
map: map,
icon: image
});
marker.setMap(map);
}
}
});
}
marcacao();
But nothing happens ...