Adding the coordinates object in the users position

Let's go ahead and do that over inside Atom, we are going to call socket.emit and emit a brand new event, one we do not have registered yet. We're going to call this one createLocationMessage:

navigator.geolocation.getCurrentPosition(function (position) {  socket.emit('createLocationMessage', {  });});

The createLocationMessage event is not going to take the standard text; instead, it's going to take those longitude and latitude coordinates. We're going to specify both of them starting with latitude; we want to set latitude equal to position.coords.latitude. This is the variable that we explored over inside of the console, and we're going to do the same thing for longitude, setting it equal ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.