Guest User

Untitled

a guest
Jun 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. socket.on('clientReady', () => {
  2. console.log('Data stream to client initiated');
  3. cursor = model.shipModel.find({}).lean().cursor();
  4. cursor.on('data', (doc) => {
  5. socket.emit('data', doc);
  6. cursor.pause();
  7. socket.on('moreData', () => {
  8. cursor.resume();
  9. });
  10. });
  11.  
  12. var mapShips = (ship) => {
  13. let element = ships.get(ship.MMSI);
  14. if (typeof element != 'undefined') {
  15. let latlng = [ship.LAT, ship.LON];
  16. element.coordinates.push(latlng);
  17. refreshPolyline(element.shipPolyline, element.coordinates);
  18. } else {
  19. let newShip = {};
  20. newShip.coordinates = [];
  21. let latlng = [ship.LAT, ship.LON];
  22. newShip.coordinates.push(latlng);
  23. newShip.shipPolyline = new L.polyline([latlng], {
  24. smoothFactor: 1,
  25. color: color,
  26. className: 'polylineStyle'
  27. }).addTo(map);
  28. ships.set(ship.MMSI, newShip);
  29. }
  30. };
Add Comment
Please, Sign In to add comment