0

我正在使用以下服务参考从纬度和经度获取位置详细信息

http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc

我将上述 URL 添加到我的服务参考类中,并尝试通过调用以下方法获取位置详细信息

 public void reverse()
       {
           string Results = "";
           try
           {
               // Set a Bing Maps key before making a request
               string key = "Bing Maps Key";

               ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest();

               // Set the credentials using a valid Bing Maps key
               reverseGeocodeRequest.Credentials = new GeoCodeService.Credentials();
               reverseGeocodeRequest.Credentials.ApplicationId = key;

               // Set the point to use to find a matching address
               GeoCodeService.Location point = new GeoCodeService.Location();
               point.Latitude = 47.608;
               point.Longitude = -122.337;

               reverseGeocodeRequest.Location = point;

               // Make the reverse geocode request
               GeocodeServiceClient geocodeService = new GeocodeServiceClient();
               **GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest);**



           }
           catch (Exception ex)
           {
               Results = "An exception occurred: " + ex.Message;

           }

但我收到以下错误消息

  1. GeoCodeService.GeoCodeServiceClient 不包含 ReverseGeocode 的定义和扩展方法

  2. 找不到 GeoCodeService.GeoCodeServiceClient。

帮助我解决问题。还告诉我这是查找位置详细信息的最佳方法。

4

1 回答 1

1

在 Windows Phone 8 中,您具有用于反向地理编码的内置 API,无需添加对 Bing 地图的服务引用:

        List<MapLocation> locations;
        ReverseGeocodeQuery query = new ReverseGeocodeQuery();
        query.GeoCoordinate = new GeoCoordinate(47.608, -122.337);
        query.QueryCompleted += (s, e) =>
            {
                if (e.Error == null && e.Result.Count > 0)
                {
                    locations = e.Result as List<MapLocation>;
                    // Do whatever you want with returned locations. 
                    // e.g. MapAddress address = locations[0].Information.Address;
                }
            };
        query.QueryAsync();
于 2013-05-22T07:54:35.787 回答