Пример #1
0
        private void Geocode(string strAddress, int wayPointIndex)
        {
            GeocodeService.GeocodeServiceClient geocodeService = new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
            geocodeService.GeocodeCompleted += new EventHandler <GeocodeService.GeocodeCompletedEventArgs>(geoCodeService_GeocodeCompleted);

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

            geocodeRequest.Credentials.ApplicationId = ((ApplicationIdCredentialsProvider)myMap.CredentialsProvider).ApplicationId;
            geocodeRequest.Query = strAddress;

            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.
            GeocodeService.GeocodeServiceClient geocodeService = new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
            geocodeService.GeocodeCompleted += new EventHandler<GeocodeService.GeocodeCompletedEventArgs>(geocodeService_GeocodeCompleted);

            // Set the credentials and the geocode query, which could be an address or location.
            GeocodeService.GeocodeRequest geocodeRequest = new GeocodeService.GeocodeRequest();
            geocodeRequest.Credentials = new GeocodeService.Credentials();
            geocodeRequest.Credentials.ApplicationId = ((ApplicationIdCredentialsProvider)MyMap.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);
        }
        /* zamienia adres na współrzędne
         * poprzez wysłanie requestu i oczekiwanie na odpowiedź
         * @args:
         * address - string z adresem który bedzie zmianeiony na wspolrzedne
         * cr - funkcja ktora zostanie wywlana gdy przyjda wspolrzedne
         * counter - ktory event z kolei jest wysylany z requestem
        */
        public void Geocode(String address, Helper.GeocodeResultReceived cr, int counter)
        {
            GeocodeResponseSendHere.Add(counter, new Helper.GeocodeResultReceived(cr));
            GeocodeServiceClient geocodeService = new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");

            GeocodeRequest geocodeRequest = new GeocodeRequest();
            {
                geocodeRequest.Credentials = new Credentials() { ApplicationId = bingMapKey };
                geocodeRequest.Query = address;
                geocodeRequest.Options = new GeocodeOptions()
                {
                    Filters = new System.Collections.ObjectModel.ObservableCollection<FilterBase>(),
                    Count = 1
                };

            };
            geocodeRequest.Options.Filters.Add(new ConfidenceFilter() { MinimumConfidence = Mobica.GeocodeService.Confidence.High });
            geocodeService.GeocodeAsync(geocodeRequest, counter);

            geocodeService.GeocodeCompleted += (sender, e) => GeocodeCompleted(sender, e);
        }
Пример #4
0
 private void getPointFromAddress(String formattedAddress)
 {
     GeocodeRequest geocodeRequest = new GeocodeRequest()
     {
         Credentials = new Credentials() { ApplicationId = BingMapKey },
         Query = formattedAddress,
         Options = new GeocodeOptions() {Count = 1 }
     };
     GeocodeService.GeocodeServiceClient geocodeService = new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
     try
     {
         geocodeService.GeocodeAsync(geocodeRequest);
         geocodeService.GeocodeCompleted += geocodeService_GeocodeCompleted;
     }
     catch (EndpointNotFoundException e)
     {
         geocodeService.Abort();
     }
 }