所以我试图使用MapService for UWP中的MapLocationFinder
类检索完整地址。
我正在使用函数FindLocationsAsync
,并且传递了以下内容:
MapLocationFinderResult result = await
MapLocationFinder.FindLocationsAsync(BuildingNumber + ", " + PostCode, null);
建筑物号为20,邮政编码为SW11 1BP。由于某种原因,这并没有返回街道名称... Address变量除了在伦敦之外不包含任何其他内容。我究竟做错了什么?我以为我可以按邮政编码和街道号进行完整的地址查找。
请检查文件Perform geocoding and reverse geocoding。您必须先指定地图authentication key,然后才能使用地图服务。为了使用地图服务,我们还需要enable the location capability。
并且您可以检查MapLocationFinderResult
Status
属性以确保查询成功。
MapLocationFinderResult result =
await MapLocationFinder.FindLocationsAsync(
BuildingNumber + ", " + PostCode, null);
if (result.Status == MapLocationFinderStatus.Success)
{
var Text = "result = (" +
result.Locations[0].Point.Position.Latitude.ToString() + "," +
result.Locations[0].Point.Position.Longitude.ToString() + ")";
}
Xaml代码
<Page.Resources>
<x:String x:Key="SeriversToken">
your token
</x:String>
</Page.Resources>
<Grid >
<Maps:MapControl Name="MapControl" MapServiceToken="{StaticResource SeriversToken}" />
</Grid>