我正在尝试构建一个使用地理定位和指南针来表示方向的应用程序。
我使用的是Xamarin.Forms和Xamarin.Mobile组件
这是地理位置代码:
private void UpdateHeading (object sender, EventArgs e)
{
#if __ANDROID__
var locator = new Geolocator (Forms.Context)
#else
var locator = new Geolocator ()
#endif
{ DesiredAccuracy = 1 };
locator.GetPositionAsync (timeout: 10000).ContinueWith (t => {
var position = t.Result;
// position.Heading == 0
}, TaskScheduler.FromCurrentSynchronizationContext());
}在iOS上,一切似乎都很好。然而,在安卓系统上,情况就不同了:大多数情况下,position.Heading被设置为0。然而,Latitude和Longitude是正确的。
我也是Android开发的新手,所以我在这里可能遗漏了一些东西。我能解决这个/什么是最好的方法有一个可靠的标题?
发布于 2015-09-13 11:23:02
正如Guilherme所指出的,Geolocator.SupportsHeading对于Android来说是错误的。
https://stackoverflow.com/questions/32528695
复制相似问题