Windows Phone ReverseGeocoding从Lat和Long获取地址

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

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。

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

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

  List 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; // Do whatever you want with returned locations. // eg MapAddress address = locations[0].Information.Address; } }; query.QueryAsync();