arturdev
arturdev

Reputation: 11039

Windows Phone 8 - GPS location speed

I want to get gps speed every time when location updates. Right now I'm doing like this:

Geolocator geolocator = new Geolocator();
geolocator.DesiredAccuracyInMeters = 0;
geolocator.MovementThreshold = 100;

geolocator.PositionChanged += geolocator_PositionChanged;

void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
    Dispatcher.BeginInvoke(() =>
    {
        SpeedBlock.Text = args.Position.Coordinate.Speed.ToString();

        LatitudeTextBlock.Text = args.Position.Coordinate.Latitude.ToString("0.00");
        LongitudeTextBlock.Text = args.Position.Coordinate.Longitude.ToString("0.00");
    });
}

This code works well for getting Latitude and Longitude, but speed always comes wrong. On emulator speed always shows 5.6 m/s. On device, its always 0.

Why? What am I doing wrong?

Upvotes: 1

Views: 5207

Answers (1)

Depechie
Depechie

Reputation: 6142

Did you check out the this article http://www.geekchamp.com/articles/understanding-the-windows-phone-location-service-how-to-get-current-gps-coordinates ?

It has as note:

Altitude, Course and Speed are only available when you specify that you want High accuracy location information by using GeoPositionAccuracy.High instead of GeoPositionAccuracy.Default and this data is retrieved from the GPS receiver. So if you try this sample with the Default accuracy, you will get NaN for altitude, speed and course. Unfortunately, although it is more accurate, High accuracy uses more power and can take longer to determine your position. If you are testing your app indoors it may still show NaN as a result for Altitude, Course and Speed, because of weak GPS signal.

Also do take a look at this example: http://www.codeproject.com/Articles/521530/A-Windows-Phone-Run-Tracking-App-in-Lines-of It show how to do your own pace calculation - but it depends on the scenario of the app.

Upvotes: 3

Related Questions