Often we need to get the user’s location through the browser. I implemented in my Meteor Js application to get this information when it is accessed by the user.
In this case we must put the function inside:
Meteor.startup ({..});
The function that you need is :
navigator.geolocation.getCurrentPosition(function (position) { {...} });
See my example below. I’m taking the data and I setting it in the session to have access into all application.
Example:
Meteor.startup(function() { if (Session.get('lat') == undefined || Session.get('lon') == undefined) { navigator.geolocation.getCurrentPosition(function(position) { Session.set('lat', position.coords.latitude); Session.set('lon', position.coords.longitude); }); } });