jamesmontemagno / GeolocatorPlugin

Geolocation plugin for Xamarin and Windows
MIT License
293 stars 158 forks source link

Add the heading of the raw GPS locations on iOS to the default position instead of relying purely on the compass for the heading #9

Open jamesmontemagno opened 8 years ago

jamesmontemagno commented 8 years ago

From @zezioen on February 12, 2016 10:2

When the UpdatePosition method is called it creates a new Location object and supplies it with the Latitude, Longitude, Accuracy, Altitude & Altitude Accuracy if available, Timestamp and Speed. It does not add the Heading supplied by the CLLocation by default.

The only way to get an 'heading' is by setting the 'includeHeading' in the StartListeningAsync to true but this does not report the heading of the GPS but where the user is pointing their device since it returns the compass heading.

The change I would like to see is to have the Compass heading be separate of the GPS heading and that the GeoLocator plugin reports the GPS heading on iOS instead of the Compass heading.

This issue doesn't seem to be an issue on Android as there the includeHeading doesn't trigger a compass heading but uses the real GPS Heading.

Copied from original issue: jamesmontemagno/Xamarin.Plugins#219

jamesmontemagno commented 8 years ago

It looks like we are calling and setting the heading:

https://github.com/jamesmontemagno/Xamarin.Plugins/blob/master/Geolocator/Geolocator/Geolocator.Plugin.iOS/GeolocationSingleUpdateDelegate.cs#L123-L139

To TrueHeading not magnetic, so it looks correct. Reading through this: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/LocationAwarenessPG/GettingHeadings/GettingHeadings.html

The only thing that I can see is that perhaps it needs to check to see if it should use the magnetic:

From iOS docs:

if (newHeading.headingAccuracy < 0)
      return;

   // Use the true heading if it is valid.
   CLLocationDirection  theHeading = ((newHeading.trueHeading > 0) ?
            newHeading.trueHeading : newHeading.magneticHeading);

   self.currentHeading = theHeading;
   [self updateHeadingDisplays];
}