Ejemplo n.º 1
0
 private void geocodeProvider_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
 {
     foreach (GeocodeResult result in e.Response.Results)
     {
         MessageBox.Show(string.Format("Longitude: {0}, Latitude: {1}, Address: {2}", result.Locations.First().Longitude, result.Locations.First().Latitude, result.DisplayName));
     }
 }
Ejemplo n.º 2
0
 private void geocodeProvider_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
 {
     foreach (GeocodeResult result in e.Response.Results)
     {
         MessageBox.Show(string.Format("Longitude: {0}, Latitude: {1}, Address: {2}", result.Locations.First().Longitude, result.Locations.First().Latitude, result.DisplayName));
     }
 }
        private void client_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            try
            {
                RoutingState  state  = e.UserState as RoutingState;
                GeocodeResult result = null;

                lock (StateSync)
                {
                    if (_geoFailed)
                    {
                        return;
                    }
                }

                if (e.Result.ResponseSummary.StatusCode != Bing.Geocode.ResponseStatusCode.Success ||
                    e.Result.Results.Count == 0)
                {
                    lock (StateSync)
                    {
                        _geoFailed = true;
                    }

                    // Report geocode error.
                    _uiDispatcher.BeginInvoke(() => Error(new RouteCalculationError(e)));

                    return;
                }

                bool doneGeocoding = false;

                lock (StateSync)
                {
                    // Only report on first result.
                    result = e.Result.Results.First();

                    // Update state object ... when all the results are set, call route.
                    state.Results[state.LocationNumber] = result;
                    doneGeocoding = state.GeocodesComplete;
                }

                if (doneGeocoding && state.GeocodesSuccessful)
                {
                    // Calculate the route.
                    CalculateRoute(state.Results);
                }
            }
            catch (Exception ex)
            {
                lock (StateSync)
                {
                    _geoFailed = true;
                }

                _uiDispatcher.BeginInvoke(() => Error(new RouteCalculationError(ex.Message, ex)));
            }
        }
Ejemplo n.º 4
0
        // GeocodeResult[] Georesults;
        void client_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            int id = Convert.ToInt32(e.UserState);

            // Georesults[id] = e.Result.Results[0];
            GeocodeResponse response = e.Result;
            //double latitude = response.Results[0].Locations[0].Latitude;
            //double longitude = response.Results[0].Locations[0].Longitude;
            //map.SetView(new GeoCoordinate(latitude, longitude), 14);
        }
        void geocodeService_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            Exception error = e.Error;
            List <LocationForQuery> locations = new List <LocationForQuery>();

            if (error == null)
            {
                try
                {
                    GeocodeResult[] results = e.Result.Results;

                    foreach (GeocodeResult result in results)
                    {
                        LocationForQuery location = new LocationForQuery()
                        {
                            name        = result.DisplayName,
                            boundingBox = new LocationRect()
                            {
                                Northeast = new GeoCoordinate(result.BestView.Northeast.Latitude, result.BestView.Northeast.Longitude),
                                Southwest = new GeoCoordinate(result.BestView.Southwest.Latitude, result.BestView.Southwest.Longitude)
                            },
                            confidence = (ViewModel.LocationServiceDataStructures.Confidence)(int) result.Confidence
                        };

                        location.location = new GeoCoordinate()
                        {
                            Latitude  = result.Locations[0].Latitude,
                            Longitude = result.Locations[0].Longitude,
                            Altitude  = result.Locations[0].Altitude
                        };

                        locations.Add(location);
                    }
                }
                catch (Exception ex)
                {
                    error = ex;
                }
            }

            Debug.Assert(error == null);

            if (LocationForAddress_Completed != null)
            {
                GeocodeState state = (GeocodeState)e.UserState;
                LocationForAddress_Completed(this,
                                             new LocationForAddressEventArgs(
                                                 locations,
                                                 state.Query,
                                                 state.SearchNearLocation,
                                                 error,
                                                 state.CallerState
                                                 ));
            }
        }
Ejemplo n.º 6
0
        void client_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            int id = Convert.ToInt32(e.UserState);

            Georesults[id] = e.Result.Results[0];
            GeocodeResponse response  = e.Result;
            double          latitude  = response.Results[0].Locations[0].Latitude;
            double          longitude = response.Results[0].Locations[0].Longitude;

            map.SetView(new GeoCoordinate(latitude, longitude), 14);

            //if (Georesults.All(m => m != null))
            //    CalculateRoute(Georesults);
        }
        void geocodeService_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            // The result is a GeocodeResponse object
            GeocodeResponse geocodeResponse = e.Result;

            if (geocodeResponse.Results.Count  > 0)
            {
                resultLoaction = new Microsoft.Maps.MapControl.Location(geocodeResponse.Results[0].Locations[0].Latitude,
                    +geocodeResponse.Results[0].Locations[0].Longitude);

                Pushpin pin = new Pushpin() { Location = resultLoaction };
                mainMap.Children.Add(pin);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Handles the GeocodeCompleted event of the geocodeService control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GeocodeCompletedEventArgs" /> instance containing the event data.</param>
        private void geocodeService_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            if (e.Result == null || e.Result.Results == null || e.Result.Results.Count == 0)
            {
                return;
            }
            var p = new Pushpin {
                Location = e.Result.Results[0].Locations[0]
            };

            mapInfo.Children.Clear();
            mapInfo.Children.Add(p);
            mapInfo.SetView(p.Location, 15);
        }
        internal RouteCalculationError(GeocodeCompletedEventArgs e)
        {
            if (e.Result == null ||
                e.Result.ResponseSummary == null ||
                string.IsNullOrEmpty(e.Result.ResponseSummary.FaultReason))
            {
                Reason = NoResults;
            }
            else
            {
                Reason = e.Result.ResponseSummary.FaultReason;
            }

            Exception = e.Error;
        }
Ejemplo n.º 10
0
        internal RouteCalculationError(GeocodeCompletedEventArgs e)
        {
            if (e.Result == null ||
                e.Result.ResponseSummary == null ||
                string.IsNullOrEmpty(e.Result.ResponseSummary.FaultReason))
            {
                Reason = NoResults;
            }
            else
            {
                Reason = e.Result.ResponseSummary.FaultReason;
            }

            Exception = e.Error;
        }
Ejemplo n.º 11
0
        void geoCode_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            System.Text.StringBuilder result = new System.Text.StringBuilder();

            if (e.Result.Results.Count > 0)
            {
                GeocodeResult svcResult = e.Result.Results[0];

                // The service returns a list of locations. We will display each of them
                foreach (Location loc in svcResult.Locations.ToList())
                {
                    latitude = loc.Latitude;
                    longitute = loc.Longitude;
                }
            }
            JSONCall();
        }
Ejemplo n.º 12
0
        public void GeocodeForDirectionsCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            if (e.Result.ResponseSummary.StatusCode != ResponseStatusCode.Success)
            {
                IsMessage = true;
                Message   = AppResources.Message_AddressNotFound;
                return;
            }

            if (e.Result.Results.Count == 0 || e.Result.Results[0].Locations.Count == 0)
            {
                IsMessage = true;
                Message   = AppResources.Message_AddressNotFound;
                return;
            }

            //set the destination place
            CurrentCity.To = e.Result.Results[0].Locations[0];


            //retrieve the stations arround destination place
            CurrentCity.ToNearStations = BikeConsts.GetNearStations(CurrentCity.To, CurrentCity.Stations, false);

            //if there was any station before selected than i can compute directions
            if (CurrentCity.CurrentStation != null)
            {
                var routes = new ObservableCollection <BikeRouteViewModel>();


                foreach (var finish in CurrentCity.ToNearStations)
                {
                    BikeRouteViewModel route = new BikeRouteViewModel();
                    route.From = CurrentCity.CurrentStation;
                    route.To   = finish;
                    route.CalculateRoute();
                    routes.Add(route);
                }

                CurrentCity.Routes = routes;
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Handles the GeocodeCompleted event of the geocodeService control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GeocodeCompletedEventArgs" /> instance containing the event data.</param>
        private void geocodeService_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            if (e.Result == null || e.Result.Results == null || e.Result.Results.Count == 0)
            {
                return;
            }
            var p = new Pushpin
            {
                Location = e.Result.Results[0].Locations[0],
                Content  = _rvList[_index]
            };

            p.DoubleTap += POnDoubleTap;
            mRvMaps.Children.Add(p);
            _rvList[_index].Latitude  = p.Location.Latitude;
            _rvList[_index].Longitude = p.Location.Longitude;
            ReturnVisitsInterface.AddOrUpdateRV(ref _rvList[_index]);
            _index++;
            if (_index < _rvList.Length)
            {
                MakeGeocodeRequest(GetGeocodeAddress(_rvList[_index]));
            }
        }
Ejemplo n.º 14
0
        private void GeocodeForStationsCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            if (e.Result.ResponseSummary.StatusCode != ResponseStatusCode.Success)
            {
                IsMessage = true;
                Message   = AppResources.Message_AddressNotFound;
                return;
            }

            if (e.Result.Results.Count == 0 || e.Result.Results[0].Locations.Count == 0)
            {
                IsMessage = true;
                Message   = AppResources.Message_AddressNotFound;
                return;
            }

            //change the from location
            CurrentCity.From = e.Result.Results[0].Locations[0];
            //load the near stations
            ShowNearStations();

            //erase the current selected route
            CurrentCity.CurrentRoute = null;
        }
Ejemplo n.º 15
0
        private void Client_GeoCodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            GeoCodeRequestCompletedEventArgs args = null;

            if (e.Result.ResponseSummary.StatusCode == GeocodeService.ResponseStatusCode.Success && e.Result.Results.Count > 0)
            {
                args = new GeoCodeRequestCompletedEventArgs();

                args.DisplayName = e.Result.Results[0].DisplayName;
                args.Address = e.Result.Results[0].Address.FormattedAddress;
                args.BestView = e.Result.Results[0].BestView;

                foreach (var loc in e.Result.Results[0].Locations)
                {
                    args.Locations.Add(new Location(loc.Latitude, loc.Longitude, loc.Altitude));
                }
            }

            OnGeoCodeRequestCompleted(args);
        }
Ejemplo n.º 16
0
 // GeocodeResult[] Georesults;
  void client_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
  {
      int id = Convert.ToInt32(e.UserState);
      
     // Georesults[id] = e.Result.Results[0];
      GeocodeResponse response = e.Result;
      //double latitude = response.Results[0].Locations[0].Latitude;
      //double longitude = response.Results[0].Locations[0].Longitude;
      //map.SetView(new GeoCoordinate(latitude, longitude), 14);
  }
        private void client_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            try
            {
                RoutingState state = e.UserState as RoutingState;
                GeocodeResult result = null;

                lock (StateSync)
                {
                    if (_geoFailed)
                        return;
                }

                if (e.Result.ResponseSummary.StatusCode != Bing.Geocode.ResponseStatusCode.Success ||
                    e.Result.Results.Count == 0)
                {
                    lock (StateSync)
                    {
                        _geoFailed = true;
                    }

                    // Report geocode error.
                    _uiDispatcher.BeginInvoke(() => Error(new RouteCalculationError(e)));

                    return;
                }

                bool doneGeocoding = false;

                lock (StateSync)
                {
                    // Only report on first result.
                    result = e.Result.Results.First();

                    // Update state object ... when all the results are set, call route.
                    state.Results[state.LocationNumber] = result;
                    doneGeocoding = state.GeocodesComplete;
                }

                if (doneGeocoding && state.GeocodesSuccessful)
                {
                    // Calculate the route.
                    CalculateRoute(state.Results);
                }
            }
            catch (Exception ex)
            {
                lock (StateSync)
                {
                    _geoFailed = true;
                }

                _uiDispatcher.BeginInvoke(() => Error(new RouteCalculationError(ex.Message, ex)));
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Handles the GeocodeCompleted event of the geocodeService control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="GeocodeCompletedEventArgs" /> instance containing the event data.</param>
 private void geocodeService_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
 {
         if (e.Result == null || e.Result.Results == null || e.Result.Results.Count == 0) return;
         var p = new Pushpin
         {
             Location = e.Result.Results[0].Locations[0],
             Content = _rvList[_index]
         };
     p.DoubleTap += POnDoubleTap;
         mRvMaps.Children.Add(p);
     _rvList[_index].Latitude = p.Location.Latitude;
     _rvList[_index].Longitude = p.Location.Longitude;
     ReturnVisitsInterface.AddOrUpdateRV(ref _rvList[_index]);
     _index++;
     if (_index < _rvList.Length)
     {
         MakeGeocodeRequest(GetGeocodeAddress(_rvList[_index]));
     }
 }
        void geocodeService_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            Exception error = e.Error;
            List<LocationForQuery> locations = new List<LocationForQuery>();

            if (error == null)
            {
                try
                {
                    GeocodeResult[] results = e.Result.Results;

                    foreach (GeocodeResult result in results)
                    {
                        LocationForQuery location = new LocationForQuery()
                        {
                            name = result.DisplayName,
                            boundingBox = new LocationRect()
                            {
                                Northeast = new GeoCoordinate(result.BestView.Northeast.Latitude, result.BestView.Northeast.Longitude),
                                Southwest = new GeoCoordinate(result.BestView.Southwest.Latitude, result.BestView.Southwest.Longitude)
                            },
                            confidence = (ViewModel.LocationServiceDataStructures.Confidence)(int)result.Confidence
                        };

                        location.location = new GeoCoordinate()
                        {
                            Latitude = result.Locations[0].Latitude,
                            Longitude = result.Locations[0].Longitude,
                            Altitude = result.Locations[0].Altitude
                        };

                        locations.Add(location);
                    }
                }
                catch (Exception ex)
                {
                    error = ex;
                }
            }

            Debug.Assert(error == null);

            if (LocationForAddress_Completed != null)
            {
                GeocodeState state = (GeocodeState)e.UserState;
                LocationForAddress_Completed(this,
                    new LocationForAddressEventArgs(
                        locations,
                        state.Query,
                        state.SearchNearLocation,
                        error,
                        state.CallerState
                        ));
            }
        }
		private void Provider_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
		{
			GeocodeResponse response = e.Response;
			listBox.ItemsSource = response.Results;
		}
Ejemplo n.º 21
0
        void geoSearchClient_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            if (e.Error != null)
            {

            }
            else
            {
                GeocodeResponse searchResponse = e.Result;
                SearchResults = searchResponse.Results;
                SearchResultUpdate(this);
            }
        }
 private void Provider_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
 {
     try
     {
         GeocodeResponse response = e.Response;
         if (response.Results.Count > 0)
         {
             Entities.AracDataList[ClientIslem.geoIndex].Adres.ADR_ADRES = AdresDuzelt(e.Response.Results[0].Address.FormattedAddress);
             Entities.AracDataList[ClientIslem.geoIndex].Adres.ADR_ULKE = AdresDuzelt(e.Response.Results[0].Address.CountryRegion);
             Entities.AracDataList[ClientIslem.geoIndex].Adres.ADR_IL = AdresDuzelt(e.Response.Results[0].Address.AdminDistrict);
             Entities.AracDataList[ClientIslem.geoIndex].Adres.ADR_SEMT = AdresDuzelt(e.Response.Results[0].Address.Locality);
             Entities.AracDataList[ClientIslem.geoIndex].Adres.ADR_CAD = AdresDuzelt(e.Response.Results[0].Address.AddressLine);
             sonKonumGrid.Rebind();
         }
         ClientIslem.geoDurum = true;
     }
     catch
     { }
 }
 private void Provider_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
 {
     GeocodeResponse response = e.Response;
     if (response.Results.Count > 0)
     {
         Location = response.Results[0].Address.FormattedAddress;
     }
     else
     {
         MessageBox.Show("Invalid Address");
     }
 }
 /// <summary>
 /// Handles the GeocodeCompleted event of the geocodeService control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="GeocodeCompletedEventArgs" /> instance containing the event data.</param>
 private void geocodeService_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
 {
         if (e.Result == null || e.Result.Results == null || e.Result.Results.Count == 0) return;
         var p = new Pushpin { Location = e.Result.Results[0].Locations[0] };
         mapInfo.Children.Clear();
         mapInfo.Children.Add(p);
         mapInfo.SetView(p.Location, 15);
 }
Ejemplo n.º 25
0
        void geocodeClient_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            RoutingState state = e.UserState as RoutingState;
            GeocodeResult result = null;
            string outString;

            try
            {
                if (e.Result.ResponseSummary.StatusCode != GeocodeService.ResponseStatusCode.Success)
                {
                    outString = "error geocoding ... status <" + e.Result.ResponseSummary.StatusCode.ToString() + ">";
                }
                else if (0 == e.Result.Results.Count)
                {
                    outString = "No result";
                }
                else
                {
                    // Only report on first result.
                    result = e.Result.Results[0];
                    outString = result.DisplayName;
                }
            }
            catch (Exception)
            {
                outString = "Exception raised";
            }

            // Update UI with geocode result.
            if (null != state.output)
            {
                state.output.Text = outString;
            }

            if (null == result)
            {
                result = new GeocodeResult();
            }

            // Update state object ... when all the results are set, call route.
            bool doneGeocoding;
            lock (lockObject)
            {
                state.results[state.locationNumber] = result;
                doneGeocoding = state.GeocodesComplete;
            }

            if (doneGeocoding && state.GeocodesSuccessful)
            {
                ////Clear any existing routes
                //ClearRoute();

                ////Calculate the route
                CalculateRoute(state.results);
            }
        }
Ejemplo n.º 26
0
        void client_GeocodeCompleted(object sender, GeocodeCompletedEventArgs e)
        {
            int id = Convert.ToInt32(e.UserState);
            Georesults[id] = e.Result.Results[0];
            GeocodeResponse response = e.Result;
            double latitude = response.Results[0].Locations[0].Latitude;
            double longitude = response.Results[0].Locations[0].Longitude;
            map.SetView(new GeoCoordinate(latitude, longitude), 14);

            //if (Georesults.All(m => m != null))
            //    CalculateRoute(Georesults);
        }