发布于 2018-07-10 11:16:34
我通过阅读本期解决了我的问题
要将来自Mysql的查询数据转换为geojson,只需尝试以下代码:
$geojson = array(
'type' => 'FeatureCollection',
'features' => array()
);
$reponses=$bdd->query('SELECT * FROM `nyc_taxi_data_2014` LIMIT 0,30 ');
while ($data=$reponses->fetch())
{
$marker = array(
'type' => 'Feature',
'features' => array(
'type' => 'Feature',
'properties' => array(
'pickup_time' => "".$data['pickup_datetime']
),
"geometry" => array(
'type' => 'Point',
'coordinates' => array(
$data['pickup_longitude'],
$data['pickup_latitude']
)
)
)
);
array_push($geojson['features'], $marker['features']);
}
echo json_encode($geojson);https://stackoverflow.com/questions/51262744
复制相似问题