this is a simple question.. I'm trying to use leaflet realtime library, but it requires to load a specific JSON output such as:
data: {"type":"Feature","geometry":{"type":"Point","coordinates":[-85.26995166666667,35.056891]},"properties":{"color":"#FFFFFF","route":"U"},"id":"118"}
so far this is all I got:
[{"type":"Feature","coordinates":["-34.66159","-59.42428"],"color":"#FFFFFF","route":"u", id:118}]
this is my PHP
$id=$row['id'];
$type=$row['type'];
$lat=$row['lat'];
$lng=$row['lng'];
$color=$row['color'];
$route=$row['route'];
$data [] = array('id'=> $id, 'type'=> $type,'coordinates'=> $lnglat = array ($lat, $lng),
'colour'=> $colour, 'route'=> $route);
$json_string = json_encode($data);
echo $json_string;
This is driving crazy... I tried everything.. I read lots of json_encode tutorial..but I can't find an example or situation such as mine.
Please, help!
Thank you!