Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I had the same problem myself - there are 2 parts to this.</p> <p>Turns out the GeoCoordinateWatcher returns the last known good position - which is almost always out of date. What I do is something like this: Check that the status is GeoPositionStatus.Ready and then ensure the datetime of the position is recent (within the last 5 mins). You can then go further and check that e.Position.Location.HorizontalAccuracy &lt;= 350 (so under 350m) - but doing this with the datetime check as well can cause the phone to take a long time to get a position the lower you set the accuracy, so it may be best to get an initial position with the date check, and then continue to try get a better position with the Accuracy check. I also start the watcher as soon as the app starts to get faster results.</p> <p>The other issue is MovementThreshold. If you do as I said above, it might still take a while before you get an accurate position, and you will likely experience the intermittent problem you mentioned where it does not fire the 2nd time (it does eventually, depending how long you wait - this can be minutes). The best thing I have found is to start the GeoCoordinateWatcher with the threshold set to 0. Once you have got an accurate position, stop the watcher, set the threshold to the actual one you want (eg 10), and then start it again. If you set this without stopping first, it will not use the new value.</p> <pre><code>&lt;!-- language: c# --&gt; GeoPositionStatus = CurrentGeoDeviceStatus; static void geoCoordWatcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e) { CurrentGeoDeviceStatus = e.Status; } void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs&lt;GeoCoordinate&gt; e) { if (gpsReady &amp;&amp; e.Position.Timestamp.DateTime.AddMinutes(5) &gt; DateTime.Now) { latitude = e.Position.Location.Latitude.ToString("0.0000000000"); longitude = e.Position.Location.Longitude.ToString("0.0000000000"); locReady = true; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload