I'm new to Xamarin and GPS solution. I would like to build an app to track the travelling mileage.
I have tried to use the Geolocator plugin from here -> https://components.xamarin.com/view/geolocatorplugin
So far, I'm able to get the current GPS location as well as trigger the PositionChanged event for new GPS location.
The issue I'm facing currently is that if I put the phone on a static location (e.g on the table) without moving it, but then I noticed the PositionChanged event will keep firing periodically and give a new GPS location, isn't the GPS location of the phone should be always the same if it is in static position without moving around?
Is there anything that I have missed out? Below is partial of my code implementation.
Please kindly advise.
Much Appreciated and Thanks.
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
locator.PositionChanged += (s, e) =>
{
try
{
var newPosition = e.Position;
Position newLogPosition = new Position(newPosition.Latitude, newPosition.Longitude);
labelNewGPS.Text = "New GPS Location : Latitude :" + newLogPosition.Latitude + ", Longitude: " + newLogPosition.Longitude; ;
}
catch (Exception ex)
{
labelErrorMessage.Text = "Trip Log encountered error - " + ex.Message.ToString();
}
};
locator.PositionError += (s, e) =>
{
labelErrorMessage.Text = "Trip Log encountered error - " + e.Error.ToString();
};
......
......
if (!locator.IsListening)
{
await locator.StartListeningAsync(1000, 0);
}