dimanche 14 février 2016

converting data from sqlite PHP

I have a number of coordinates stored in a sqlite database. I need these coordinates to be used in a heatmap on leaflet. I'm using the following plugin: http://ift.tt/1dYmDIh

The data needs to be in the following format:

var addressPoints = [
[52.344161, 4.912279],
[52.342425, 4.913038],
[52.342034, 4.913256],
[52.341987, 4.912462]];

I extract the data from the sqlite database in PHP using:

$db = new SQLite3('jwtrack.sqlite');
$results = $db->query("SELECT coord FROM trackjw");
while ($row = $results->fetchArray()) {
echo json_encode($row['coord']);
}
$db->close();

The data retrieved looks like:

"52.344161000, 4.912279000""52.342425000, 4.913038200""52.342034000, 4.913256000""52.341987000, 4.912462000""52.342336000, 4.912106000"

How can I get the SQLite data inserted in 'var addressPoints' in a correct manner?

Thansk in advance,

JWB

Aucun commentaire:

Enregistrer un commentaire