//This method accepts a geocode query string as well as a ‘waypoint index’, which will be used to track each asynchronous geocode request. private void Geocode(string strAddress, int waypointIndex) { // Create the service variable and set the callback method using the GeocodeCompleted property. findroute.geocodeservice.GeocodeServiceClient geocodeService = new findroute.geocodeservice.GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); geocodeService.GeocodeCompleted += new EventHandler<findroute.geocodeservice.GeocodeCompletedEventArgs>(geocodeService_GeocodeCompleted); // Set the credentials and the geocode query, which could be an address or location. findroute.geocodeservice.GeocodeRequest geocodeRequest = new findroute.geocodeservice.GeocodeRequest(); geocodeRequest.Credentials = new Credentials(); geocodeRequest.Credentials.ApplicationId = ((ApplicationIdCredentialsProvider)map1.CredentialsProvider).ApplicationId; geocodeRequest.Query = strAddress; // Make the asynchronous Geocode request, using the ‘waypoint index’ as // the user state to track this request and allow it to be identified when the response is returned. geocodeService.GeocodeAsync(geocodeRequest, waypointIndex); }
//This method accepts a geocode query string as well as a ‘waypoint index’, which will be used to track each asynchronous geocode request. private void Geocode(string strAddress, int waypointIndex) { // Create the service variable and set the callback method using the GeocodeCompleted property. findroute.geocodeservice.GeocodeServiceClient geocodeService = new findroute.geocodeservice.GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); geocodeService.GeocodeCompleted += new EventHandler <findroute.geocodeservice.GeocodeCompletedEventArgs>(geocodeService_GeocodeCompleted); // Set the credentials and the geocode query, which could be an address or location. findroute.geocodeservice.GeocodeRequest geocodeRequest = new findroute.geocodeservice.GeocodeRequest(); geocodeRequest.Credentials = new Credentials(); geocodeRequest.Credentials.ApplicationId = ((ApplicationIdCredentialsProvider)map1.CredentialsProvider).ApplicationId; geocodeRequest.Query = strAddress; // Make the asynchronous Geocode request, using the ‘waypoint index’ as // the user state to track this request and allow it to be identified when the response is returned. geocodeService.GeocodeAsync(geocodeRequest, waypointIndex); }