private void GeocodeAddress(string address, RoutingState state)
{
var request = new GeocodeRequest()
{
Culture = CultureInfo.CurrentUICulture.Name,
Query = address,
// Don't raise exceptions.
ExecutionOptions = new UsingBingMaps.Bing.Geocode.ExecutionOptions()
{
SuppressFaults = true
},
// Only accept results with high confidence.
Options = new GeocodeOptions()
{
Filters = new ObservableCollection<FilterBase>
{
new ConfidenceFilter()
{
MinimumConfidence = UsingBingMaps.Bing.Geocode.Confidence.High
}
}
}
};
// Get credentials and only then place an async call on the geocode service.
_credentialsProvider.GetCredentials(credentials =>
{
// Pass in credentials for web services call.
// Replace with your own Credentials.
request.Credentials = credentials;
// Make asynchronous call to fetch the data.
_geocodeClient.GeocodeAsync(request, state);
});
}
#endregion