Skip to content
Snippets Groups Projects

trying to draw the exact traject of the bus

Merged Maria Paramonova requested to merge draiwing_on_map_back into master
1 file
+ 25
0
Compare changes
  • Side-by-side
  • Inline
+ 25
0
@@ -56,6 +56,7 @@ io.on('connection', socket => { // server automatically listens for "connection"
lat: row.latitude,
lng: row.longitude,
id: row.id_arret,
destination: row.destination,
}
}));
// for (row of positions) {
@@ -86,6 +87,14 @@ io.on('connection', socket => { // server automatically listens for "connection"
// }, err => console.log(err));
// });
socket.on('get-road', line => {
getPreciseRoad(line).then( coords => {
socket.emit('road', coords);
});
});
socket.on('get-demo', () => {
@@ -169,9 +178,25 @@ getStopsForLine = (line) => {
else resolve(rows);
});
});
}
getPreciseRoad = (line) => {
return new Promise((resolve, reject) => {
con.query(`SELECT direction, ST_AsGeoJSON(parcours) as coords FROM trace WHERE ligne LIKE "${line}"`, (err, res) => {
if (err) {
console.log(err);
reject(err);
} else {
resolve(res[0])
console.log(res);
}
})
});
}
sendPositionToDb = (p, id) => {
Loading