我Listview_ItemTapped通过使用Geolocator插件在xamarin.forms中获取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);
}
Run Code Online (Sandbox Code Playgroud)
我尝试删除,locator.DesiredAccuracy = 50;但有时它会立即工作,有时它不会.