我正在使用Geolocator
插件在xamarin.forms中通过Listview_ItemTapped
获取GPS位置,以捕获纬度和经度。但是获取位置平均需要15秒以上的时间。是否有任何方法可以立即获取位置。
if (CrossGeolocator.Current.IsGeolocationEnabled == false)
{
await DisplayAlert("Notification", "Geolocation is Unavailable ", "Ok");
}
else
{
Application.Current.Properties["LATITUDE"] = null;
Application.Current.Properties["LONGITUDE"] = null;
var locator = CrossGeolocator.Current;
//locator.DesiredAccuracy = 50;
var position = await locator.GetPositionAsync(timeoutMilliseconds: 50000);
Application.Current.Properties["LATITUDE"] = position.Latitude;
Application.Current.Properties["LONGITUDE"] = position.Longitude;
await Navigation.PushAsync(new RetailerDetailsPage(), false);
}
我尝试删除 locator.DesiredAccuracy = 50;
,但有时它会立即起作用,有时不会。