[英]not get location using Plugin.Geolocator in xamarin
我想做一个简单的应用程序来获取我的当前位置,我正在使用Geolocator插件查询我的位置,但是当我调用方法GetPositionAsync()时,它抛出了异常错误,该应用程序有权访问我手机中的位置。 有我的代码:
try
{
if ( locator.IsGeolocationEnabled == false )
{
await App.Current.MainPage.DisplayAlert("Error", "location is not enable", "aceptar");
return;
}
if( locator.IsGeolocationAvailable == false)
{
await App.Current.MainPage.DisplayAlert("Error", "location is not aviable", "aceptar");
return;
}
var position = await locator.GetPositionAsync(TimeSpan.MaxValue);
GeoPos = position.Latitude.ToString();
}
catch (Exception ex)
{
await App.Current.MainPage.DisplayAlert("Error", ex.ToString(), "aceptar");
}
其将我发送到catch异常并显示此错误: 错误消息
感谢大家的帮助!
据我所知,索引超出范围异常可能发生的唯一合理位置是在某些外部代码中。
也许分配给GeoPos
的异常导致了效果...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.