public GeoViewModel()
 {
     this.Items = new ObservableCollection<GeoItemViewModel>();
     this.IsAddressResult = true;
     NotifyPropertyChanged("AddressResultVisibility");
     geocodeClient = new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
     geocodeClient.GeocodeCompleted += new EventHandler<GeocodeService.GeocodeCompletedEventArgs>(geocodeClient_GeocodeCompleted);
 }
        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);
        }
Example #3
0
        private void GeocodeAddress(string input)
        {
            using (GeocodeService.GeocodeServiceClient client = new GeocodeService.GeocodeServiceClient("CustomBinding_IGeocodeService"))
            {
                GeocodeService.GeocodeRequest request = new GeocodeService.GeocodeRequest();
                request.Credentials = new Credentials()
                {
                    ApplicationId = (App.Current.Resources["BingCredentials"] as ApplicationIdCredentialsProvider).ApplicationId
                };
                request.Query = Address;
                GeocodeResult = client.Geocode(request).Results[0];

                LocationAddress = GeocodeResult.Address.FormattedAddress;
                Latitude        = GeocodeResult.Locations[0].Latitude;
                Longitude       = GeocodeResult.Locations[0].Longitude;
                Location        = new Location(Latitude, Longitude);
                PinVisible      = Visibility.Visible;
            }
        }
Example #4
0
        private string AddressFromLatLng(string pLatitude, string pLongitude)
        {
            GeocodeService.ReverseGeocodeRequest reverseGeocodeRequest = new GeocodeService.ReverseGeocodeRequest();

            // Set the credentials using a valid Bing Maps key
            reverseGeocodeRequest.Credentials = new Credentials();
            reverseGeocodeRequest.Credentials.ApplicationId = m_BingKey;

            // Set the point to use to find a matching address
            GeocodeService.Location point = new GeocodeService.Location();
            point.Latitude = Convert.ToDouble(pLatitude);
            point.Longitude = Convert.ToDouble(pLongitude);

            reverseGeocodeRequest.Location = point;

            // Make the reverse geocode request
            GeocodeService.GeocodeServiceClient geocodeService =
            new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
            GeocodeService.GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest);

            vPosition = geocodeResponse.Results[0].DisplayName;

            if (vPosition != null)
                StartSearch(vPosition);

            return vPosition;
        }
    private void GeocodeAddress(string input)
    {
      using (GeocodeService.GeocodeServiceClient client = new GeocodeService.GeocodeServiceClient("CustomBinding_IGeocodeService"))
      {
        GeocodeService.GeocodeRequest request = new GeocodeService.GeocodeRequest();
        request.Credentials = new Credentials() { ApplicationId = (App.Current.Resources["BingCredentials"] as ApplicationIdCredentialsProvider).ApplicationId };
        request.Query = Address;
        GeocodeResult = client.Geocode(request).Results[0];

        LocationAddress = GeocodeResult.Address.FormattedAddress;
        Latitude = GeocodeResult.Locations[0].Latitude;
        Longitude = GeocodeResult.Locations[0].Longitude;
        Location = new Location(Latitude, Longitude);
        PinVisible = Visibility.Visible;
      }
    }
        /* 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);
        }
        // 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);
        }
Example #8
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();
     }
 }
Example #9
0
 private void getAddressFromPoint(double latitude, double longitude)
 {
     ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest()
     {
         Credentials = new Credentials() { ApplicationId = BingMapKey },
         Location = new Location() { Latitude = latitude, Longitude = longitude }
     };
     GeocodeService.GeocodeServiceClient geocodeService = new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
     try
     {
         geocodeService.ReverseGeocodeAsync(reverseGeocodeRequest);
         geocodeService.ReverseGeocodeCompleted += geocodeService_ReverseGeocodeCompleted;
     }
     catch (EndpointNotFoundException e)
     {
         geocodeService.Abort();
     }
 }
Example #10
0
 public CustomAdressResolver()
 {
     proxy = new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
     proxy.ReverseGeocodeCompleted += new EventHandler<GeocodeService.ReverseGeocodeCompletedEventArgs>(proxy_ReverseGeocodeCompleted);
 }
        /// <summary>
        /// Converts GPS coordinates into address.
        /// </summary>
        /// <param name="coordinates">"latitue, longitude"</param>
        /// <returns>address + ; + country + ; + city</returns>
        public string MakeReverseGeocodeRequest(string coordinates)
        {
            try
            {
                CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
                // Set a Bing Maps key before making a request

                GeocodeService.ReverseGeocodeRequest reverseGeocodeRequest = new GeocodeService.ReverseGeocodeRequest();

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

                string[] digits = coordinates.Split(',');
                double lat = double.Parse(digits[0].Trim(), culture);
                double lon = double.Parse(digits[1].Trim(), culture);

                // Set the point to use to find a matching address
                GeocodeService.Location point = new GeocodeService.Location();
                point.Latitude = lat;
                point.Longitude = lon;

                reverseGeocodeRequest.Location = point;

                // Make the reverse geocode request
                GeocodeService.GeocodeServiceClient geocodeService =
                new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
                GeocodeService.GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest);

                if (geocodeResponse.Results.Count() == 0)
                {
                    return "No location found.";
                }
                return geocodeResponse.Results[0].Address.AddressLine + ";" + geocodeResponse.Results[0].Address.CountryRegion + ";" + geocodeResponse.Results[0].Address.Locality;

            }
            catch (Exception)
            {
                return "An exception occurred.";

            }
        }
        /// <summary>
        /// Converts the address into GPS coordinates (latitude and longitude)
        /// </summary>
        /// <param name="address">The address to be converted.</param>
        /// <returns>"latitude, longitude"</returns>
        public string MakeGeocodeRequest(string address)
        {
            try
            {
                CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
                // Set a Bing Maps key before making a request

                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 = address;

                // 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);

                if (geocodeResponse.Results.Count() == 0)
                {
                    return "No location found.";
                }
                return geocodeResponse.Results[0].Locations[0].Latitude.ToString(culture) + "," + geocodeResponse.Results[0].Locations[0].Longitude.ToString(culture);

            }
            catch (Exception)
            {
                return "An exception occurred.";
            }
        }