Export (0) Print
Expand All

GeocodeServiceClient.Geocode Method

This documentation is no longer available on MSDN. It is available as a CHM or PDF download. For the newest Geocoding, Imagery, Routing and Traffic services, see the Bing Maps REST Services

Finds a geographic location based on a request that may include the address, place, or entity type names to find.

public GeocodeResponse Geocode(GeocodeRequest request)


A GeocodeRequest object that contains the header and parameter information for the service operation.

private void MakeGeocodeRequest()
string Results = "";
// Set a Bing Maps key before making a request
string key = "Bing Maps Key";

GeocodeService.GeocodeRequest geocodeRequest = new GeocodeService.GeocodeRequest();

// Set the credentials using a valid Bing Maps Key
geocodeRequest.Credentials = new GeocodeService.Credentials();
geocodeRequest.Credentials.ApplicationId = key;

// Set the full address query
geocodeRequest.Query = "1 Microsoft Way, Redmond, WA";

// Set the options to only return high confidence results
GeocodeService.ConfidenceFilter[] filters = new GeocodeService.ConfidenceFilter[1];
filters[0] = new GeocodeService.ConfidenceFilter();
filters[0].MinimumConfidence = GeocodeService.Confidence.High;

GeocodeService.GeocodeOptions geocodeOptions = new GeocodeService.GeocodeOptions();
geocodeOptions.Filters = filters;

geocodeRequest.Options = geocodeOptions;

// Make the geocode request
GeocodeService.GeocodeServiceClient geocodeService =
new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
GeocodeService.GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest);

Results = geocodeResponse.Results[0].DisplayName;

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



© 2015 Microsoft