Reputation: 1832
I'm messing about with the Bing Maps WPF control and SOAP services, trying to reverse geocode a point. I tried to implement some code from this project, specifically this block of code:
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;
}
However, when I try to implement it, I'm being told: Error: The type or namespace name 'Credentials' does not exist in the namespace 'GeocodeTest.GeocodeService' (are you missing an assembly reference?)
This error occurs on the line:
reverseGeocodeRequest.Credentials = new GeocodeService.Credentials();
Curious, I decided to take a look at the service reference through the object browser. Apparently, my GeocodeService
doesn't even have a Credentials
member. So now the question is:
Upvotes: 1
Views: 1142
Reputation: 1832
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();
Upvotes: 2