当前位置: 首页 > 编程语言 > C#

在WindowsPhone8.1上获取CivicAddress分享

时间:2023-04-11 03:35:23 C#

();geolocator.DesiredAccuracyInMeters=100;varposition=awaitgeolocator.GetGeopositionAsync();//获取国家varcountry=position.CivicAddress.Country;抛出NullReferenceException,因为CivicAddress字段为空。我知道没有适用于Windows8的CivicAddress提供程序。我想检查一下WindowsPhone8.1是否属于这种情况。如果是这样,我如何获取/编写CivicAddress提供程序?您将需要使用ReverseGeocoding-有关MSDN的更多信息。对于Windows运行时,您可以为此目的使用MapLocationFinder.FindLocationsAtAsync:vargeolocator=newGeolocator();geolocator.DesiredAccuracyInMeters=100;地理位置position=awaitgeolocator.GetGeopositionAsync();//反向地理编码BasicGeopositionmyLocation=newBasicGeoposition{=position.Coordinate.Longitude,Latitude=position.Coordinate.Latitude};地理点pointToReverseGeocode=newGeopoint(myLocation);MapLocationFinderResult结果=awaitMapLocationFinder.FindLocationsAtAsync(pointToReverseGeocode);//这里也不应该检查是否为null以及在这种情况下应该做什么stringcountry=result.Locations[0].Address.Country;如果你想获得工作的地址,那么我建议你使用ReverseGeocodeQueryAPI和你在GeolocatorAPI上获得的位置,参考实现我在github上有一个例子,可以在https://github.com/nokia找到-developer/MAPS-samples/trees/master/RevGeoCoding否则你也可以试试这个从GeoCoordinateshttp://msdn获取公民地址。microsoft.com/en-us/library/system.device.location.civicaddress(v=vs.110).aspx以上是C#学习教程:在Win在dowsPhone8.1上获取CivicAddress分享的所有内容。如果对你有用,需要进一步了解C#学习教程,希望大家多多关注。本文收集自网络,不代表立场。如涉及侵权请点击维权联系管理员删除转载请注明出处: