使用楼号和邮政编码找回确切的地址-UWP-MapService

问题描述 投票:0回答:1

所以我试图使用MapService for UWP中的MapLocationFinder类检索完整地址。

我正在使用函数FindLocationsAsync,并且传递了以下内容:

MapLocationFinderResult result = await
                    MapLocationFinder.FindLocationsAsync(BuildingNumber + ", " + PostCode, null);

建筑物号为20,邮政编码为SW11 1BP。由于某种原因,这并没有返回街道名称... Address变量除了在伦敦之外不包含任何其他内容。我究竟做错了什么?我以为我可以按邮政编码和街道号进行完整的地址查找。

c# uwp bing-maps
1个回答
0
投票

请检查文件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>
© www.soinside.com 2019 - 2024. All rights reserved.