1

我正在搞乱 Bing Maps WPF 控件和 SOAP 服务,试图对一个点进行反向地理编码。我试图从这个项目中实现一些代码,特别是这段代码:

private string ReverseGeocodePoint(string locationString)
          {
              string results = "";
              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();
              string[] digits = locationString.Split(';');

              point.Latitude = double.Parse(digits[0].Trim());
              point.Longitude = double.Parse(digits[1].Trim());

              reverseGeocodeRequest.Location = point;

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

              if (geocodeResponse.Results.Length > 0)
                  results = geocodeResponse.Results[0].DisplayName;
              else
                  results = "No Results found";

              return results;
          }

但是,当我尝试实现它时,我被告知:Error: The type or namespace name 'Credentials' does not exist in the namespace 'GeocodeTest.GeocodeService' (are you missing an assembly reference?)此错误发生在线:

reverseGeocodeRequest.Credentials = new GeocodeService.Credentials();

好奇,我决定通过对象浏览器看一下服务引用。显然,我GeocodeService的甚至没有Credentials会员。所以现在的问题是:

  • 我应该自己添加成员吗?如果是这样,我该怎么做?
  • 如果没有,在提供凭证方面有哪些替代方案?
4

1 回答 1

2

The Credentials namespace/type doesn't exist for the service reference GeocodeText.GeocodeService. Instead, you have to use the Credentials from the Bing Maps WPF Control. The statement would look like so:

reverseGeocodeRequest.Credentials = new Microsoft.Maps.MapControl.WPF.Credentials();
于 2012-07-22T04:26:43.400 回答