Michael,
If you want to compare the user's location to that what is stored in the database, have a look at the google maps module. Then you can retrieve the lat and long by geocoding requests based on the information available. Then calculate the distance between the user's lat long and those in the database. There's a module for that available in the appstore as well. If you want to compare distance to other logged in users just get their lat and long and store it in the database and then calculate the distance.
Michael, Did you already created mobile versions of your app? Because that you should do first. In the navigation of the phone start with a microflow that retrieves the lat long of the phone (see appstore https://appstore.home.mendix.com/link/app/1380/Mendix/Geolocation-for-PhoneGap) and store this in the database. You could create some scheduled event that updates these values. Then you can do the calculations as Erwin mentioned.
Regards,
Ronald