Esempio n. 1
0
        // convert address to lat/lon
        public MyWaypoint Geocode(string address)
        {
            GeocodeRequest locationRequest = new GeocodeRequest();

            // Set the credentials using a valid Bing Maps key
            locationRequest.Credentials = new BingGeocodeService.Credentials();
            locationRequest.Credentials.ApplicationId = m_bingMapKey;
            locationRequest.Query = address;

            // Make the calculate route request
            GeocodeServiceClient geocodeService  = new BingGeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
            GeocodeResponse      geocodeResponse = geocodeService.Geocode(locationRequest);

            MyWaypoint returnPoint = new MyWaypoint();

            if (geocodeResponse.Results.Length > 0)
            {
                returnPoint.Latitude  = geocodeResponse.Results[0].Locations[0].Latitude;
                returnPoint.Longitude = geocodeResponse.Results[0].Locations[0].Longitude;
                //returnPoint.Altitude = GetAltitude(returnPoint.Latitude, returnPoint.Longitude);
                returnPoint.Altitude = 0.0;
            }

            return(returnPoint);
        }
Esempio n. 2
0
        private BingGeocodeService.GeocodeResult GeocodeAddress(string address)
        {
            BingGeocodeService.GeocodeResult result = null;

            using (BingGeocodeService.GeocodeServiceClient client =
                       new BingGeocodeService.GeocodeServiceClient("CustomBinding_IGeocodeService"))
            {
                BingGeocodeService.GeocodeRequest request = new BingGeocodeService.GeocodeRequest();
                request.Credentials = new Credentials()
                {
                    ApplicationId = (App.Current.Resources["MyCredentials"] as
                                     ApplicationIdCredentialsProvider).ApplicationId
                };
                request.Query = address;
                result        = client.Geocode(request).Results[0];
            }

            return(result);
        }