I\'m trying to develop an application that should be something like a game. The user would have some locations in a city and he would have to do something on each location. In o
I think that the problem occurs, because you give too little time for Geolocator to make a proper readout with Geolocator.GetGeopositionAsync - timeout:
Geoposition geoposition = await geolocator.GetGeopositionAsync(TimeSpan.FromMilliseconds(500), TimeSpan.FromSeconds(1));
You give it only 1 second, while getting more accurate position takes time.
My example:
Geolocator geolocator;
Geoposition geoposition;
public MainPage()
{
this.InitializeComponent();
geolocator = new Geolocator();
geolocator.DesiredAccuracyInMeters = 10;
geolocator.ReportInterval = 0;
myButton.Click += async (sender, e) =>
{
geoposition = await geolocator.GetGeopositionAsync();
string latitude = geoposition.Coordinate.Latitude.ToString("0.0000000000");
string Longitude = geoposition.Coordinate.Longitude.ToString("0.0000000000");
string Accuracy = geoposition.Coordinate.Accuracy.ToString("0.0000000000");
};
}
The code above returs a position (in my case) with accuracy of ~35 meters, BUT after waiting about 20-30 seconds. Note also that accuracy depends on numer of available sattelites.
Also some remarks from MSDN:
set Geolocator.ReportInterval to 0:
Apps that do require real-time data should set ReportInterval to 0, to indicate that no minimum interval is specified. On Windows, when the report interval is 0, the app receives events at the frequency that the most accurate location source sends them. On Windows Phone, the app will receive updates at a rate dependent on the accuracy requested by the app.
set Geolocator.DesiredAccuracyInMeters to 10 meters:
◾If the user is trying to share his position, the app should request an accuracy of about 10 meters.
try to dealy between starting Geolocator and reding it:
Consider start-up delay. The first time an app requests location data, there might be a short delay (1-2 seconds) while the location provider starts up. Consider this in the design of your app's UI. For instance, you may want to avoid blocking other tasks pending the completion of the call to GetGeopositionAsync.