如何在Windows Phone 8中找到当前位置的名称?

时间:2013-09-11 01:25:35

标签: windows-phone-8

我可以使用Geoposition类获取纬度和经度。如何在Windows Phone 8中找到当前位置的名称?

2 个答案:

答案 0 :(得分:3)

您在Windows Phone 8中有一个用于反向地理编码的内置API。您可以按照以下方式执行此操作,例如,查找城市名称:

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

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

答案 1 :(得分:1)

这称为反向地理编码。 Google将此作为其地理编码API的一部分提供。具体参考是here

您可以使用简单的HTTP请求调用其API:

http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true

他们将返回JSON格式的人类可读名称列表。