Home > Software engineering >  Tracking users locations in ASP.NET Core
Tracking users locations in ASP.NET Core

Time:10-01

I would like to track the location of multiple users who use my website through their mobile browsers, in a centralised dashboard.

My environment is ASP.NET Core. i tried open layers to get user's current coordinates (langitude, latitude). the idea i am thinking of is to send coordinates to server every second, storing it at database , then plotting them , is this the right approach

CodePudding user response:

const successCallback = (position) => {
     // Call your API here to save the position (latitude,longitude) of 
     user
};

const errorCallback = (error) => {
  console.log(error);
};

navigator.geolocation.getCurrentPosition(successCallback, errorCallback);

You can get your users current location using JavaScript geolocation API and create a mapping of the location and users, then use that data to set up your dashboard.

  • Related