Note that there are some explanatory texts on larger screens.

plurals
  1. POLocation service returning previous coordinates on WP7
    primarykey
    data
    text
    <p>I'm using the code from <a href="http://create.msdn.com/en-US/education/quickstarts/Developing_with_the_Windows_Phone_GPS_%28Location_Services%29" rel="nofollow">the official site</a>, and I am consistently seeing the same behavior on multiple test devices - instead of getting the current location of the device, it gets the previous location (up to 30 miles away, where I was an hour ago).</p> <pre><code> private void setupMaps() { watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); watcher.MovementThreshold = 10.0f; watcher.StatusChanged += new EventHandler&lt;GeoPositionStatusChangedEventArgs&gt;(watcher_statusChanged); watcher.PositionChanged += new EventHandler&lt;GeoPositionChangedEventArgs&lt;GeoCoordinate&gt;&gt;(watcher_PositionChanged); new Thread(startLocServInBackground).Start(); } void startLocServInBackground() { watcher.TryStart(true, TimeSpan.FromSeconds(60)); } void watcher_statusChanged(object sender, GeoPositionStatusChangedEventArgs e) { switch (e.Status) { case GeoPositionStatus.Disabled: // The Location Service is disabled or unsupported. // Check to see if the user has disabled the location service. if (watcher.Permission == GeoPositionPermission.Denied) { // the user has disabled LocServ on their device. showMessage("Location is required but it is disabled. Turn it on in Settings"); } else { showMessage("Location is not functioning on this phone. Sorry, Crux cannot run"); } break; case GeoPositionStatus.Initializing: // The location service is initializing. LoadingInfo.Text = "finding location"; break; case GeoPositionStatus.NoData: // The Location Service is working, but it cannot get location data // due to poor signal fidelity (most likely) // this fired intermittently when data was coming back :/ //MessageBox.Show("Location data is not available."); break; case GeoPositionStatus.Ready: // The location service is working and is receiving location data. //statusTextBlock.Text = "Location data is available."; LoadingInfo.Text = "Location found"; // THIS FIRES AFTER POSITION CHANGED HAS STOPPED FIRING break; } } private void initPostPanel() { PostPanel.Visibility = Visibility.Visible; } void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs&lt;GeoCoordinate&gt; e) { // update the textblock readouts. latitude = e.Position.Location.Latitude.ToString("0.0000000000"); longitude = e.Position.Location.Longitude.ToString("0.0000000000"); // THIS FIRES TWICE, BEFORE STATUS IS FIRED AS READY. THEN THIS DOESN'T CALL AGAIN } </code></pre> <p>What I would expect to have happen is to get a continuous series of calls to PositionChanged after StatusChanged is called with a Status of Ready. If the calls continued after Ready, I expect I would eventually get the correct coordinates - but it never calls after that point.</p> <p>This does not occur with the emulator, only on the actual device (making this extremely difficult to test - since it actually involves driving between each test!)</p> <p>I am running the source code from the tutorial as well, and it does roughly the same.</p> <p>Can anyone tell me more about the expected behavior here and how I get what I need - which is simply a set of coordinates for the device at the current location when the app is being used.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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