GeocodeServiceClient.ReverseGeocode Method
Bing Services
Finds geographic entities and addresses for a specified map location (known as reverse geocoding).
|
request |
A ReverseGeocodeRequest object that contains the header and parameter information for the service operation. |
Returns a GeocodeResponse Class, which contains a GeocodeResult Class array.
private void MakeReverseGeocodeRequest() { string Results = ""; try { // Set a Bing Maps key before making a request string key = "Bing Maps Key"; GeocodeService.ReverseGeocodeRequest reverseGeocodeRequest = new GeocodeService.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 GeocodeService.GeocodeServiceClient geocodeService = new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); GeocodeService.GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest); Results = geocodeResponse.Results[0].DisplayName; } catch (Exception ex) { Results = "An exception occurred: " + ex.Message; } }