【发布时间】:2016-07-21 05:05:55
【问题描述】:
我是 xamarin Android 的新手......我有一个应用程序可以显示用户当前的纬度和经度,这似乎正在工作......
现在,从纬度和经度,我尝试使用 API Geocoder 获取地址。我通过了正确的纬度和经度,但它没有给我任何地址,尽管我看不到任何错误。
以下是我的代码:-
async Task<Address> ReverseGeocodeCurrentLocationAsync(double Latitude, double Longitude)
{
Geocoder geocoder = new Geocoder(this);
IList<Address> addressList = await
geocoder.GetFromLocationAsync(Latitude, Longitude, 10); // ???????? its not wrking....Here, Im properly able to pass latitude and longitude still issue getting adress.
IList<Address> testaddresses = await geocoder.GetFromLocationAsync(42.37419, -71.120639, 1); // ???????? i tried both sync and async method but not wrking....
Address address = addressList.FirstOrDefault();
return address;
}
// 调用部分 地址address = await ReverseGeocodeCurrentLocationAsync(location.Latitude, location.Longitude);
另外,您可以在 :https://github.com/4pawan/XamarinDroidSample 找到源代码
请让我知道我做错了什么以及如何纠正?
问候, 帕万
【问题讨论】: