Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- socket.on('clientReady', () => {
- console.log('Data stream to client initiated');
- cursor = model.shipModel.find({}).lean().cursor();
- cursor.on('data', (doc) => {
- socket.emit('data', doc);
- cursor.pause();
- socket.on('moreData', () => {
- cursor.resume();
- });
- });
- var mapShips = (ship) => {
- let element = ships.get(ship.MMSI);
- if (typeof element != 'undefined') {
- let latlng = [ship.LAT, ship.LON];
- element.coordinates.push(latlng);
- refreshPolyline(element.shipPolyline, element.coordinates);
- } else {
- let newShip = {};
- newShip.coordinates = [];
- let latlng = [ship.LAT, ship.LON];
- newShip.coordinates.push(latlng);
- newShip.shipPolyline = new L.polyline([latlng], {
- smoothFactor: 1,
- color: color,
- className: 'polylineStyle'
- }).addTo(map);
- ships.set(ship.MMSI, newShip);
- }
- };
Add Comment
Please, Sign In to add comment