【问题标题】:Windows Phone - Getting Device Location by showing Street Names and not Co-ordinates?Windows Phone - 通过显示街道名称而不是坐标来获取设备位置?
【发布时间】:2014-02-19 11:07:46
【问题描述】:

我只是想知道如何获取设备的当前位置。现在,当我尝试使用 Geolocator 执行此操作时,它不起作用。它只是给了我经度和纬度。我不想要这个我想要街道或城市或郊区等的名称......一个例子是诺基亚的HERE Transit 应用程序。当您转到“附近”选项卡时,您会看到一张地图,其下方是街道名称、郊区,然后是城市和邮政编码。

我该怎么做?我现在拥有的是:

        Geolocator geolocator = new Geolocator();
        geolocator.DesiredAccuracyInMeters = 50;
        try
        {
            Geoposition geoposition = await geolocator.GetGeopositionAsync();
            test.Text = geoposition.Coordinate.Latitude.ToString("0.00");
            testt.Text = geoposition.Coordinate.Longitude.ToString("0.00");
        }
        catch (UnauthorizedAccessException)
        {

        } 

基本上这给了我经度和纬度。也许我可以使用这些来获取街道或城市等的名称,但是如何?

在编程时,我从未真正使用过 MAPS 或任何与 Location 相关的东西。那么我该如何实现呢?

谢谢

【问题讨论】:

标签: c# windows-phone-7 location maps


【解决方案1】:

这称为反向地理编码。 这是一个示例代码:

MapAddress address;
ReverseGeocodeQuery query = new ReverseGeocodeQuery();
query.GeoCoordinate = myGeoCoordinate;
query.QueryCompleted += (s, e) =>
   {
        if (e.Error != null)
            return;

        address = e.Result[0].Information.Address;
    };
query.QueryAsync();

该 API 在 Windows Phone 8 上可用,我看到问题标记为 WP7,但由于您似乎使用 Geolocator API,我猜您使用的是 WP8。否则,您必须使用这种服务:Find a Location by Point

【讨论】:

  • 谢谢!正是我想要的!
  • 在 Windows Phone 8 中也可以在离线模式下工作?
猜你喜欢
  • 1970-01-01
  • 2013-10-31
  • 1970-01-01
  • 1970-01-01
  • 2010-12-18
  • 1970-01-01
  • 1970-01-01
  • 2014-07-30
  • 1970-01-01
相关资源
最近更新 更多