Exemplo n.º 1
0
        private void Navigate(List <GeoCoordinate> geolist)
        {
            Geolocator MyGeolocator = new Geolocator();

            MyGeolocator.DesiredAccuracyInMeters = 5;
            try
            {
                MyQuery                 = new RouteQuery();
                MyQuery.Waypoints       = geolist;
                MyQuery.QueryCompleted += QueryCompleted;
                //MyQuery.QueryCompleted += ((sender, e) =>
                //    {
                //        if (e.Error == null)
                //        {
                //            MyQuery = new RouteQuery();
                //            MyQuery.Waypoints = geolist;
                //            MyQuery.QueryCompleted += QueryCompleted;
                //        }
                //    });
                MyQuery.QueryAsync();
            }
            catch (UnauthorizedAccessException)
            {
                MessageBox.Show("Location is disabled in phone settings or capabilities are not checked.");
            }
        }
Exemplo n.º 2
0
        private async void GetCoordinates()
        {
            Geolocator MyGeolocator = new Geolocator();
            MyGeolocator.DesiredAccuracyInMeters = 5;
            Geoposition MyGeoPosition = null;
            try
            {
                MyGeoPosition = await MyGeolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10));
                currentGeoCoordinate = ConvertGeocoordinate(MyGeoPosition.Coordinate);

                myMap.Center = currentGeoCoordinate;
                myMap.ZoomLevel = 15;

                if (!comeinGeoCoordinate.IsUnknown)
                {
                    List<GeoCoordinate> geoCoordinates = new List<GeoCoordinate>();
                    geoCoordinates.Add(currentGeoCoordinate);
                    geoCoordinates.Add(comeinGeoCoordinate);

                    RouteQuery routeQuery = new RouteQuery();
                    routeQuery.Waypoints = geoCoordinates;
                    routeQuery.QueryCompleted += routeQuery_QueryCompleted;
                    routeQuery.QueryAsync();
                }
            }
            catch (UnauthorizedAccessException)
            {
                MessageBox.Show("Location is disabled in phone settings");
            }
            catch (Exception ex)
            {
            }
        }
        /// <summary>
        /// Get the route from me to a friend
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void FriendList_Route(object sender, RoutedEventArgs e)
        {
            try
            {
                //get index
                int    selectedIndex = App.ViewModel.Friends.IndexOf((sender as MenuItem).DataContext as Friend);
                Friend friend        = App.ViewModel.Friends[selectedIndex];

                //Add start and end points
                List <GeoCoordinate> MyCoordinates = new List <GeoCoordinate>();
                MyCoordinates.Add(new GeoCoordinate(Me.Latitude, Me.Longitude));
                MyCoordinates.Add(new GeoCoordinate(friend.Latitude, friend.Longitude));

                //send the query
                MyQuery                 = new RouteQuery();
                MyQuery.Waypoints       = MyCoordinates;
                MyQuery.QueryCompleted += MyQuery_QueryCompleted;
                try
                {
                    MyQuery.QueryAsync();
                }
                catch (Exception)
                {
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something gotta wrong.");
            }
        }
Exemplo n.º 4
0
        void GenerarMap()
        {
            //double lat = 13.3039361;
            //double longi = -87.1818977;

            //double myLat = 13.309102541101671;
            //double myLongi = -87.18679750841795;

            myCoordinates.Add(new System.Device.Location.GeoCoordinate(lat, longi));
            myCoordinates.Add(new System.Device.Location.GeoCoordinate(myLat, myLongi));

            

            //myGeocode = new GeocodeQuery();
            //myGeocode.GeoCoordinate = new System.Device.Location.GeoCoordinate(myLat, myLongi);
            //myGeocode.QueryCompleted += myGeocode_QueryCompleted;
            //myGeocode.QueryAsync();

            myQuery = new RouteQuery();
            myQuery.Waypoints = myCoordinates;
            myQuery.QueryCompleted += myQuery_QueryCompleted;
            myQuery.QueryAsync();
            mapPlace.Center = new System.Device.Location.GeoCoordinate(myLat, myLongi);

           
            MapLayer myLayer = new MapLayer();

            Pushpin myPushpin = new Pushpin();
            MapOverlay myOverlay = new MapOverlay();
            myPushpin.GeoCoordinate = new System.Device.Location.GeoCoordinate(myLat, myLongi);

            myPushpin.Content = "I'm Here";

            myOverlay.Content = myPushpin;
            myOverlay.GeoCoordinate = new System.Device.Location.GeoCoordinate(myLat, myLongi);
            myLayer.Add(myOverlay);

            Pushpin pushpin = new Pushpin();
            MapOverlay overlay = new MapOverlay();
            pushpin.GeoCoordinate = new System.Device.Location.GeoCoordinate(lat, longi);

            pushpin.Content = PlaceName;

            overlay.Content = pushpin;
            overlay.GeoCoordinate = new System.Device.Location.GeoCoordinate(lat, longi);
            myLayer.Add(overlay);

            mapPlace.Layers.Add(myLayer);

            //Animacion del mapa
            mapPlace.SetView(new System.Device.Location.GeoCoordinate()
            {
                Latitude = lat,
                Longitude = longi
            }, 16, Microsoft.Phone.Maps.Controls.MapAnimationKind.Parabolic);


            
        }
Exemplo n.º 5
0
 /// <summary>
 /// add direction points to show direction
 /// </summary>
 /// <param name="fromLocation"></param>
 /// <param name="toLocation"></param>
 /// <returns></returns>
 public void Direction(System.Device.Location.GeoCoordinate fromLocation, System.Device.Location.GeoCoordinate toLocation)
 {
     RouteQuery routeQuery = new RouteQuery();
     routeQuery.Waypoints = new List<System.Device.Location.GeoCoordinate>() { fromLocation, toLocation };
     routeQuery.QueryCompleted += routeQuery_QueryCompleted;
     routeQuery.TravelMode = TravelMode.Driving;
     routeQuery.QueryAsync();
 }
Exemplo n.º 6
0
 /// <summary>
 /// Method to initiate a route query.
 /// </summary>
 /// <param name="route">List of geocoordinates representing the route</param>
 private void CalculateRoute(List <GeoCoordinate> route)
 {
     ShowProgressIndicator(AppResources.CalculatingRouteProgressText);
     MyRouteQuery                 = new RouteQuery();
     MyRouteQuery.TravelMode      = _travelMode;
     MyRouteQuery.Waypoints       = route;
     MyRouteQuery.QueryCompleted += RouteQuery_QueryCompleted;
     MyRouteQuery.QueryAsync();
 }
Exemplo n.º 7
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (sender == Hplus)
            {
                map1.Heading = (map1.Heading + 12);
            }
            else if (sender == Hmins)
            {
                map1.Heading = (map1.Heading - 12);
            }
            else if (sender == TrMod)
            {
                if (RTrav == TravelMode.Driving)
                {
                    RTrav         = TravelMode.Walking;
                    TrMod.Content = "Walk";
                }
                else
                {
                    RTrav         = TravelMode.Driving;
                    TrMod.Content = "Drive";
                }
            }
            else if (sender == Optim)
            {
                if (ROpti == RouteOptimization.MinimizeTime)
                {
                    ROpti         = RouteOptimization.MinimizeDistance;
                    Optim.Content = "Shortest";
                }
                else
                {
                    ROpti         = RouteOptimization.MinimizeTime;
                    Optim.Content = "Quickest";
                }
            }
            else if (sender == Rutte)
            {
                if (geoQ.IsBusy == true)
                {
                    geoQ.CancelAsync();
                }

                geoQ.InitialHeadingInDegrees = map1.Heading;

                geoQ.RouteOptimization = ROpti;
                geoQ.TravelMode        = RTrav;

                List <GeoCoordinate> MyWayPoints = new List <GeoCoordinate>();
                MyWayPoints.Add(startMark.GeoCoordinate);
                MyWayPoints.Add(enddMark.GeoCoordinate);

                geoQ.Waypoints = MyWayPoints;
                geoQ.QueryAsync();
            }
        }
Exemplo n.º 8
0
 void Mygeocodequery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     if (e.Error == null)
     {
         MyQuery = new RouteQuery();
         MyCoordinates.Add(e.Result[0].GeoCoordinate);
         MyQuery.Waypoints       = MyCoordinates;
         MyQuery.QueryCompleted += MyQuery_QueryCompleted;
         MyQuery.QueryAsync();
         Mygeocodequery.Dispose();
     }
 }
Exemplo n.º 9
0
 private void Mygeocodequery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
 {
     if (e.Error == null)
     {
         MyQuery = new RouteQuery();
         MyCoordinates.Add(e.Result[0].GeoCoordinate);
         MyQuery.Waypoints = MyCoordinates;
         MyQuery.QueryCompleted += MyQuery_QueryCompleted;
         MyQuery.QueryAsync();
         Mygeocodequery.Dispose();
     }
 }
Exemplo n.º 10
0
 private void FindRoute()
 {
     RouteQuery query = new RouteQuery()
     {
         TravelMode = TravelMode.Driving,
         Waypoints = new List<GeoCoordinate>()
         {
             TransitionData.start_location, 
             TransitionData.finish_location, 
         }
     };
     query.QueryCompleted += routeQuery_QueryCompleted;
     query.QueryAsync();
 }
        private void vm_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "TrackPoints" && vm.TrackPoints.Count > 1)
            {
                RouteQuery query = new RouteQuery()
                {
                    Waypoints  = vm.TrackPoints,
                    TravelMode = TravelMode.Driving,
                };

                query.QueryCompleted += query_QueryCompleted;
                query.QueryAsync();
            }
        }
Exemplo n.º 12
0
        async void RequestDirections()
        {
            rq.QueryCompleted += routeQuery_QueryCompleted;

            if (!rq.IsBusy)
            {
                List <GeoCoordinate> routeCoordinates = new List <GeoCoordinate>();
                routeCoordinates.Add(new GeoCoordinate(48.860339, 2.337599));
                routeCoordinates.Add(new GeoCoordinate(48.8583, 2.2945));

                rq.Waypoints = routeCoordinates;
                rq.QueryAsync();

                map.Center = new GeoCoordinate(48.8583, 2.2945); //Center map on last coordinates
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Geo Code Query completed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        void ShowRoute()
        {
            try
            {
                myRouteQuery = new RouteQuery();
                myRouteCoordinates.Add(new GeoCoordinate(Convert.ToDouble(App.LocalServiceLatitude), Convert.ToDouble(App.LocalServiceLongitude)));
                myRouteQuery.Waypoints       = myRouteCoordinates;
                myRouteQuery.TravelMode      = TravelMode.Driving;
                myRouteQuery.QueryCompleted += myRouteQuery_QueryCompleted;
                myRouteQuery.QueryAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 14
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (Tag != null)
            {
                Cmd[] cmds = (Tag as Eqlogic).cmds;
                Cmd   cmd  = cmds.GetCmdByConfigModeName("travelDistance");
                if (cmd != null)
                {
                    LblTrajet.Text = cmd.ToString("");
                }
                cmd = cmds.GetCmdByConfigModeName("travelTime");
                if (cmd != null)
                {
                    LblTemp.Text = cmd.ToString("");
                }
                cmd = cmds.GetCmdByConfigModeName("distance");
                if (cmd != null)
                {
                    LblDistance.Text = cmd.ToString("");
                }

                cmd = cmds.GetCmdByConfigModeName("dynamic");
                if (cmd != null)
                {
                    string   name  = cmd.name;
                    string   coord = cmd.ToString("");
                    string[] tmp   = coord.Split(',');
                    MyCoordinates.Add(new GeoCoordinate(double.Parse(tmp[0], CultureInfo.InvariantCulture), double.Parse(tmp[1], CultureInfo.InvariantCulture)));
                    cmd = cmds.GetCmdByConfigModeName("fixe");
                    if (cmd != null)
                    {
                        LblTitle.Text = cmd.name + "=>" + name;
                        coord         = cmd.ToString("");
                        tmp           = coord.Split(',');
                        MyCoordinates.Add(new GeoCoordinate(double.Parse(tmp[0], CultureInfo.InvariantCulture), double.Parse(tmp[1], CultureInfo.InvariantCulture)));
                        RouteQuery MyQuery = new RouteQuery();
                        MyQuery.TravelMode      = TravelMode.Driving;
                        MyQuery.Waypoints       = MyCoordinates;
                        MyQuery.QueryCompleted += MyQuery_QueryCompleted;
                        MyQuery.QueryAsync();
                    }

                    MapControl.ZoomLevel = 16;
                    MapControl.Center    = MyCoordinates[0];
                }
            }
        }
Exemplo n.º 15
0
        public ItineraryDetails()
        {
            InitializeComponent();
            //check tinh trang hanh trinh
            if (GlobalData.selectedItinerary.status.Equals(null))
            {

            }
            else
            {

            }
            MapOverlay overlay = new MapOverlay();
            //set point on map
            //draw start poit
            overlay = UserControls.MarkerDraw.DrawMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long));
            wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long));
            layer.Add(overlay);
            //draw end point
            overlay = UserControls.MarkerDraw.DrawMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long));
            wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long));
            layer.Add(overlay);

            mapItineraryDetails.Layers.Add(layer);
            //driection
            routeQuery = new RouteQuery();
            //GeocodeQuery Mygeocodequery = null;

            routeQuery.QueryCompleted += routeQuery_QueryCompleted;
            routeQuery.TravelMode = TravelMode.Driving;
            routeQuery.RouteOptimization = RouteOptimization.MinimizeDistance;
            routeQuery.Waypoints = wayPoints;
            routeQuery.QueryAsync();

            //set itinerary info
            txtDescription.Text = GlobalData.selectedItinerary.description;
            txtStartAddress.Text = GlobalData.selectedItinerary.start_address;
            txtEndAddress.Text = GlobalData.selectedItinerary.end_address;
            txtCost.Text = GlobalData.selectedItinerary.cost;
            txtPhone.Text = GlobalData.selectedItinerary.phone;
            txtLeaveDay.Text = GlobalData.selectedItinerary.leave_date;
            txtDistance.Text = GlobalData.selectedItinerary.distance.ToString();
            txtDuration.Text = GlobalData.selectedItinerary.duration.ToString();

        }
Exemplo n.º 16
0
        private void reverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            if (e.Error == null)
            {
                geoCoordenadas.Add(e.Result[0].GeoCoordinate);

                routeQuery = new RouteQuery()
                {
                    Waypoints = geoCoordenadas
                };

                routeQuery.QueryCompleted += routeQuery_QueryCompleted;
                routeQuery.QueryAsync();

                reverseGeocodeQuery.Dispose();
                GC.SuppressFinalize(reverseGeocodeQuery);
            }
        }
Exemplo n.º 17
0
        public ItineraryDetails()
        {
            InitializeComponent();
            //check tinh trang hanh trinh
            if (GlobalData.selectedItinerary.status.Equals(null))
            {
            }
            else
            {
            }
            MapOverlay overlay = new MapOverlay();

            //set point on map
            //draw start poit
            overlay = UserControls.MarkerDraw.DrawMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long));
            wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long));
            layer.Add(overlay);
            //draw end point
            overlay = UserControls.MarkerDraw.DrawMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long));
            wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long));
            layer.Add(overlay);

            mapItineraryDetails.Layers.Add(layer);
            //driection
            routeQuery = new RouteQuery();
            //GeocodeQuery Mygeocodequery = null;

            routeQuery.QueryCompleted   += routeQuery_QueryCompleted;
            routeQuery.TravelMode        = TravelMode.Driving;
            routeQuery.RouteOptimization = RouteOptimization.MinimizeDistance;
            routeQuery.Waypoints         = wayPoints;
            routeQuery.QueryAsync();

            //set itinerary info
            txtDescription.Text  = GlobalData.selectedItinerary.description;
            txtStartAddress.Text = GlobalData.selectedItinerary.start_address;
            txtEndAddress.Text   = GlobalData.selectedItinerary.end_address;
            txtCost.Text         = GlobalData.selectedItinerary.cost;
            txtPhone.Text        = GlobalData.selectedItinerary.phone;
            txtLeaveDay.Text     = GlobalData.selectedItinerary.leave_date;
            txtDistance.Text     = GlobalData.selectedItinerary.distance.ToString();
            txtDuration.Text     = GlobalData.selectedItinerary.duration.ToString();
        }
Exemplo n.º 18
0
        private void CreateDirectionsPivotItem()
        {
            var currentPosition = LocationService.CurrentPosition;

            if (currentPosition != null && !currentPosition.IsUnknown && Settings.GetBool(Setting.LocationServicesEnabled))
            {
                var routeQuery = new RouteQuery
                {
                    RouteOptimization = RouteOptimization.MinimizeTime,
                    TravelMode        = TravelMode.Walking,
                    Waypoints         = new[] {
                        currentPosition,
                        new GeoCoordinate(departuresAndArrivalsTable.Station.Location.Lat, departuresAndArrivalsTable.Station.Location.Long)
                    },
                };

                routeQuery.QueryCompleted += OnRouteQueryCompleted;
                routeQuery.QueryAsync();
            }
        }
Exemplo n.º 19
0
        public async Task <Direction> WalkDistanceAsync(double sourceLat, double sourceLon, double targetLat, double targetLon)
        {
            Task     completeTask = new Task(() => { });
            double   length       = -1;
            TimeSpan time;

            var query = new RouteQuery
            {
                TravelMode = TravelMode.Walking,
                Waypoints  = new GeoCoordinate[] { new GeoCoordinate(sourceLat, sourceLon), new GeoCoordinate(targetLat, targetLon) }
            };

            query.QueryCompleted += delegate(object sender, QueryCompletedEventArgs <Microsoft.Phone.Maps.Services.Route> e)
            {
                if (e.Error == null)
                {
                    var resultRoute = e.Result;
                    length = resultRoute.LengthInMeters;
                    time   = resultRoute.EstimatedDuration;
                    //MapRoute MyMapRoute = new MapRoute(resultRoute);
                    query.Dispose();
                }
                completeTask.Start();
            };
            query.QueryAsync();

            await completeTask;

            if (length == -1)
            {
                return(null);
            }
            else
            {
                var res = new Direction {
                    DistanceInMeters = length, EstimatedDuration = time
                };
                return(res);
            }
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (App.Current.Resources.Contains("FileSelected"))
            {
                RouteDetails.Visibility = System.Windows.Visibility.Visible;
                int selection = Convert.ToInt32(App.Current.Resources["FileSelected"].ToString());
                await OpenFile(App.DataModel[selection].FileName);

                routeQuery.TravelMode      = TravelMode.Driving;
                routeQuery.QueryCompleted += rq_QueryCompleted;
                routeQuery.Waypoints       = waypoints;
                routeQuery.QueryAsync();
                App.Current.Resources.Remove("FileSelected");
            }
            else
            {
                RouteDetails.Visibility = System.Windows.Visibility.Collapsed;
                if (gcw == null)
                {
                    TrackMap.MapElements.Clear();
                    TrackMap.ColorMode                 = MapColorMode.Light;
                    TrackMap.CartographicMode          = MapCartographicMode.Road;
                    TrackMap.LandmarksEnabled          = true;
                    TrackMap.PedestrianFeaturesEnabled = true;
                    TrackMap.Center    = new GeoCoordinate(11.0134, -74.8023);
                    TrackMap.ZoomLevel = 16;
                    TrackMap.Layers.Add(UserLayer);

                    gcw = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
                    gcw.PositionChanged += gcw_PositionChanged;
                    gcw.StatusChanged   += gcw_StatusChanged;

                    if (!App.InBackground)
                    {
                        TrackMap.MapElements.Add(polyline);
                    }
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Geo Code Query completed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mygeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            if (e.Error == null)
            {
                try
                {
                    myRouteQuery = new RouteQuery();

                    myRouteCoordinates.Add(e.Result[0].GeoCoordinate);

                    myRouteQuery.Waypoints = myRouteCoordinates;

                    myRouteQuery.QueryCompleted += myRouteQuery_QueryCompleted;

                    myRouteQuery.QueryAsync();

                    mygeocodeQuery.Dispose();
                }
                catch (Exception)
                {
                }
            }
        }
 private void MappingRoute(object sender, System.EventArgs e)
 {
     routeQuery = new RouteQuery();
     routeQuery.TravelMode = TravelMode.Walking;
     routeQuery.QueryCompleted += routeQuery_QueryCompleted;
     routeQuery.Waypoints = waypoints;
     routeQuery.QueryAsync();
 }
Exemplo n.º 23
0
        void geocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {
            if (e.Error == null)
            {
                GeoCoordinate geoCoordinate = e.Result[0].GeoCoordinate;
                myMap.Center = e.Result[0].GeoCoordinate;
                List<GeoCoordinate> geoCoordinates=new List<GeoCoordinate>();
                geoCoordinates.Add(e.Result[0].GeoCoordinate);
                geoCoordinates.Add(e.Result[1].GeoCoordinate);

                RouteQuery routeQuery = new RouteQuery();
                routeQuery.Waypoints = geoCoordinates;
                routeQuery.QueryCompleted += routeQuery_QueryCompleted;
                routeQuery.QueryAsync();
            }
        }
Exemplo n.º 24
0
 /// <summary>
 /// Method to initiate a route query.
 /// </summary>
 /// <param name="route">List of geocoordinates representing the route</param>
 private void CalculateRoute(List<GeoCoordinate> route)
 {
     ShowProgressIndicator(AppResources.CalculatingRouteProgressText);
     MyRouteQuery = new RouteQuery();
     MyRouteQuery.TravelMode = _travelMode;
     MyRouteQuery.Waypoints = route;
     MyRouteQuery.QueryCompleted += RouteQuery_QueryCompleted;
     MyRouteQuery.QueryAsync();
 }
Exemplo n.º 25
0
 /// <summary>
 /// CÁI NÀY LÀ ĐỂ KẺ LẠI MỘT ĐưỜNG MAP TRONG QUÁ TRÌNH TAXI ĐANG DI CHuyển
 /// </summary>
 /// <param name="startPosition"></param>
 /// <param name="endPosition"></param>
 private void TrackingRouteOnMap(GeoCoordinate startPosition, GeoCoordinate endPosition)
 {
     driverMapTrackerQuery = new RouteQuery()
     {
         TravelMode = TravelMode.Driving,
         Waypoints = new List<GeoCoordinate>()
     {
         startPosition, 
         endPosition
     },
         RouteOptimization = RouteOptimization.MinimizeTime
     };
     driverMapTrackerQuery.QueryCompleted += driverTrackingRouteQuery_QueryCompleted;
     driverMapTrackerQuery.QueryAsync();
 }
Exemplo n.º 26
0
        void MygeocodequerylocationSearch_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {

            List<GeoCoordinate> r;
            if (e.Result.Count > 0)
            {
                _myQueryLocation = new RouteQuery();
                r = new List<GeoCoordinate> { new GeoCoordinate(_myLatitude, _myLongitude), e.Result[0].GeoCoordinate };
                _myQueryLocation.Waypoints = r;
                _myQueryLocation.QueryCompleted += MyQuerySearchLocation_QueryCompleted;
                _myQueryLocation.QueryAsync();
                //Mygeocodequerylocation.Dispose();
            }

        }
Exemplo n.º 27
0
        public DriverItineraryDetails()
        {
            InitializeComponent();

            //hanh trinh chua ai dang ki
            if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CREATED))
            {
                //create button update hanh trinh
                Button btnUpdate = new Button();
                btnUpdate.Content = "Cập Nhật";
                btnUpdate.Click  += btnUpdate_Click;
                gridInfo.Children.Add(btnUpdate);
                Grid.SetRow(btnUpdate, 5);

                //create button huy hanh trinh
                Button btnDelete = new Button();
                btnDelete.Content = "Xóa";
                btnDelete.Click  += btnDelete_Click;
                gridInfo.Children.Add(btnDelete);
                Grid.SetRow(btnDelete, 6);

                //cho phep sua doi dien di va diem den
            }
            //dang doi driver accept
            else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CUSTOMER_ACCEPTED))
            {
                //tao button accept va button huy customer accept
                //create button accept hanh trinh
                Button btnAccept = new Button();
                btnAccept.Content = "Chấp Nhận";
                btnAccept.Click  += btnAccept_Click;
                gridInfo.Children.Add(btnAccept);
                Grid.SetRow(btnAccept, 5);

                //create button reject hanh trinh
                Button btnReject = new Button();
                btnReject.Content = "Từ Chối";
                btnReject.Click  += btnReject_Click;
                gridInfo.Children.Add(btnReject);
                Grid.SetRow(btnReject, 6);
            }
            //driver da accepted
            else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_DRIVER_ACCEPTED))
            {
                //
                //create button start hanh trinh
                Button btnStart = new Button();
                btnStart.Content = "Start";
                btnStart.Click  += btnStart_Click;
                gridInfo.Children.Add(btnStart);
                Grid.SetRow(btnStart, 6);
            }
            //ongoing
            else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_ONGOING))
            {
                //create button tracking hanh trinh
                Button btnTracking = new Button();
                btnTracking.Content = "Tracking";
                btnTracking.Click  += btnTracking_Click;
                gridInfo.Children.Add(btnTracking);
                Grid.SetRow(btnTracking, 6);

                //btn Finish
            }
            //hanh trinh da ket thuc
            else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_FINISHED))
            {
            }

            //draw 2 points on map
            startPointOverlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long));
            wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long));
            mapLayer.Add(startPointOverlay);

            endPointOverlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long));
            wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long));
            mapLayer.Add(endPointOverlay);

            //set zoom and center point
            mapItineraryDetails.ZoomLevel = 14;
            mapItineraryDetails.Center    = startPointOverlay.GeoCoordinate;

            mapItineraryDetails.Layers.Add(mapLayer);

            //draw route
            routeQuery = new RouteQuery();
            //GeocodeQuery Mygeocodequery = null;
            routeQuery.QueryCompleted   += routeQuery_QueryCompleted;
            routeQuery.TravelMode        = TravelMode.Driving;
            routeQuery.RouteOptimization = RouteOptimization.MinimizeDistance;
            routeQuery.Waypoints         = wayPoints;
            routeQuery.QueryAsync();

            //set text 2 points
            txtboxStart.Text = GlobalData.selectedItinerary.start_address;
            txtboxEnd.Text   = GlobalData.selectedItinerary.end_address;

            //set text itinerary info

            txtbDistance.Text    = GlobalData.selectedItinerary.distance.ToString();
            txtbDescription.Text = GlobalData.selectedItinerary.description;
            txtbCost.Text        = GlobalData.selectedItinerary.cost;

            //xu ly ngay thang
            string datetimeString = GlobalData.selectedItinerary.leave_date.Trim();

            DateTime datetime = DateTimes.DatetimeConvert.convertDateTimeFromString(datetimeString);

            datePicker.Value = datetime;
            timePicker.Value = datetime;

            //datePicker.Value = GlobalData.selectedItinerary.da
        }
Exemplo n.º 28
0
        public ItineraryDetails()
        {
            InitializeComponent();
            //check status cua customer
            if (GlobalData.customer_status.Equals(2))
            {
                //check tinh trang hanh trinh
                //hanh trinh chua ai dang ki
                if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CREATED))
                {
                    //create button register itinerary
                    Button btnAcceptItinerary = new Button();
                    btnAcceptItinerary.Content = "Accept Itinerary";
                    btnAcceptItinerary.Click  += btnAcceptItinerary_Click;
                    gridMap.Children.Add(btnAcceptItinerary);
                    Grid.SetRow(btnAcceptItinerary, 1);
                }
                //dang doi driver accept
                else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CUSTOMER_ACCEPTED))
                {
                    //tao trang thai dang doi accept, tao nut huy hanh trinh
                    Button btnCancelItinerary = new Button();
                    btnCancelItinerary.Content = "Cancel Itinerary";
                    btnCancelItinerary.Click  += btnCancelItinerary_Click;
                    gridMap.Children.Add(btnCancelItinerary);
                    Grid.SetRow(btnCancelItinerary, 1);
                }
                //driver da accepted
                else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_DRIVER_ACCEPTED))
                {
                    //tao trang thai da duoc accept, tao nut
                }
                //ongoing
                else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_ONGOING))
                {
                    //tao trang thai da duoc accept, tao nut
                    //create button tracking hanh trinh
                    Button btnTracking = new Button();
                    btnTracking.Content = "Tracking";
                    btnTracking.Click  += btnTracking_Click;
                    gridInfo.Children.Add(btnTracking);
                    Grid.SetRow(btnTracking, 6);
                }
                //hanh trinh da ket thuc
                else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_FINISHED))
                {
                }
            }
            else if (GlobalData.customer_status.Equals(1))
            {
            }
            else
            {
            }

            MapOverlay overlay = new MapOverlay();

            //set point on map
            //draw start poit
            overlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long));

            wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long));

            mapItineraryDetails.Center = overlay.GeoCoordinate;
            layer.Add(overlay);
            //draw end point
            overlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long));
            wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long));
            layer.Add(overlay);
            mapItineraryDetails.Layers.Add(layer);

            mapItineraryDetails.ZoomLevel = 14;


            //driection
            routeQuery = new RouteQuery();
            //GeocodeQuery Mygeocodequery = null;
            routeQuery.QueryCompleted   += routeQuery_QueryCompleted;
            routeQuery.TravelMode        = TravelMode.Driving;
            routeQuery.RouteOptimization = RouteOptimization.MinimizeDistance;
            routeQuery.Waypoints         = wayPoints;
            routeQuery.QueryAsync();
            //set itinerary info
            txtDescription.Text  = GlobalData.selectedItinerary.description;
            txtStartAddress.Text = GlobalData.selectedItinerary.start_address;
            txtEndAddress.Text   = GlobalData.selectedItinerary.end_address;
            txtCost.Text         = GlobalData.selectedItinerary.cost;
            txtPhone.Text        = GlobalData.selectedItinerary.phone;
            txtLeaveDay.Text     = GlobalData.selectedItinerary.leave_date;
            txtDistance.Text     = GlobalData.selectedItinerary.distance.ToString();
            txtDuration.Text     = GlobalData.selectedItinerary.duration.ToString();
        }
        /// <summary>
        /// Geo Code Query completed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        void ShowRoute()
        {
            try
            {

                myRouteQuery = new RouteQuery();
                myRouteCoordinates.Add(new GeoCoordinate(Convert.ToDouble(App.LocalServiceLatitude), Convert.ToDouble(App.LocalServiceLongitude)));
                myRouteQuery.Waypoints = myRouteCoordinates;
                myRouteQuery.TravelMode = TravelMode.Driving;
                myRouteQuery.QueryCompleted += myRouteQuery_QueryCompleted;
                myRouteQuery.QueryAsync();


            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 30
0
        public ItineraryDetails()
        {
            InitializeComponent();
            //check status cua customer
            if (GlobalData.customer_status.Equals(2))
            {
                //check tinh trang hanh trinh
                //hanh trinh chua ai dang ki
                if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CREATED))
                {
                    //create button register itinerary
                    Button btnAcceptItinerary = new Button();
                    btnAcceptItinerary.Content = "Accept Itinerary";
                    btnAcceptItinerary.Click += btnAcceptItinerary_Click;
                    gridMap.Children.Add(btnAcceptItinerary);
                    Grid.SetRow(btnAcceptItinerary, 1);
                }
                //dang doi driver accept
                else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CUSTOMER_ACCEPTED))
                {
                    //tao trang thai dang doi accept, tao nut huy hanh trinh
                    Button btnCancelItinerary = new Button();
                    btnCancelItinerary.Content = "Cancel Itinerary";
                    btnCancelItinerary.Click += btnCancelItinerary_Click;
                    gridMap.Children.Add(btnCancelItinerary);
                    Grid.SetRow(btnCancelItinerary, 1);
                }
                //driver da accepted
                else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_DRIVER_ACCEPTED))
                {
                    //tao trang thai da duoc accept, tao nut 
                }
                //ongoing
                else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_ONGOING))
                {
                    //tao trang thai da duoc accept, tao nut
                    //create button tracking hanh trinh
                    Button btnTracking = new Button();
                    btnTracking.Content = "Tracking";
                    btnTracking.Click += btnTracking_Click;
                    gridInfo.Children.Add(btnTracking);
                    Grid.SetRow(btnTracking, 6);
                }
                //hanh trinh da ket thuc
                else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_FINISHED))
                {

                }
            }
            else if (GlobalData.customer_status.Equals(1))
            {

            }
            else
            {

            }

            MapOverlay overlay = new MapOverlay();
            //set point on map
            //draw start poit
            overlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long));
            
            wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long));

            mapItineraryDetails.Center = overlay.GeoCoordinate;
            layer.Add(overlay);
            //draw end point
            overlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long));
            wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long));
            layer.Add(overlay);
            mapItineraryDetails.Layers.Add(layer);

            mapItineraryDetails.ZoomLevel = 14;
            

            //driection
            routeQuery = new RouteQuery();
            //GeocodeQuery Mygeocodequery = null;
            routeQuery.QueryCompleted += routeQuery_QueryCompleted;
            routeQuery.TravelMode = TravelMode.Driving;
            routeQuery.RouteOptimization = RouteOptimization.MinimizeDistance;
            routeQuery.Waypoints = wayPoints;
            routeQuery.QueryAsync();
            //set itinerary info
            txtDescription.Text = GlobalData.selectedItinerary.description;
            txtStartAddress.Text = GlobalData.selectedItinerary.start_address;
            txtEndAddress.Text = GlobalData.selectedItinerary.end_address;
            txtCost.Text = GlobalData.selectedItinerary.cost;
            txtPhone.Text = GlobalData.selectedItinerary.phone;
            txtLeaveDay.Text = GlobalData.selectedItinerary.leave_date;
            txtDistance.Text = GlobalData.selectedItinerary.distance.ToString();
            txtDuration.Text = GlobalData.selectedItinerary.duration.ToString();
        }
Exemplo n.º 31
0
 private void DrawLinePathOnMap()
 {
     for (int i = 0; i < ObjRootObjectJourney.data.latlong.Count - 1; i++)
     {
         geo1 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[i].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[i].longitude));
         geo2 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[i + 1].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[i + 1].longitude));
         query = new RouteQuery()
        {
            TravelMode = TravelMode.Driving,
            Waypoints = new List<GeoCoordinate>()
              {
                  geo1,
                  geo2 
              }
        };
         query.QueryCompleted += routeQuery_QueryCompleted;
         query.QueryAsync();
     }
     progressBar1.Visibility = Visibility.Collapsed;
 }
Exemplo n.º 32
0
        private void CalculateRoute(double latitudeA, double longitudeA, double latitudeB, double longitudeB, Color color)
        {
            RouteQuery geoQ = new RouteQuery();
            geoQ.QueryCompleted += geoQ_QueryCompleted;
            if (geoQ.IsBusy == true)
            {
                geoQ.CancelAsync();
            }
            List<GeoCoordinate> MyWayPoints = new List<GeoCoordinate>();
            MyWayPoints.Add(new GeoCoordinate(latitudeA,longitudeA));
            MyWayPoints.Add(new GeoCoordinate(latitudeB, longitudeB));

            geoQ.Waypoints = MyWayPoints;
            geoQ.QueryAsync();

        }
 private void Mygeocodequery_QueryCompleted1(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
 {
     if (e.Error == null)
     {
         try
         {
             MyQuery1 = new RouteQuery();
             MyCoordinates1.Add(userCoordinate);
             MyCoordinates1.Add(alternative.Coordinate);
             MyQuery1.Waypoints = MyCoordinates1;
             MyQuery1.TravelMode = TravelMode.Walking;
             MyQuery1.QueryCompleted += MyQuery_QueryCompleted1;
             MyQuery1.QueryAsync();
             Mygeocodequery1.Dispose();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Exemplo n.º 34
0
 /// <summary>
 /// CÁI NÀY ĐỂ VẼ ĐƯỜNG ĐI GIỮA 2 điểm
 /// </summary>
 /// <param name="startPosition"></param>
 /// <param name="endPosition"></param>
 private void GetRouteOnMap(GeoCoordinate startPosition, GeoCoordinate endPosition)
 {
     if (driverMapRoute != null)
     {
         map_DriverMap.RemoveRoute(driverMapRoute);
         driverMapRoute = null;
         driverQuery = null;
         map_DriverMap.Layers.Remove(driverMapLayer);
     }
     driverQuery = new RouteQuery()
     {
         TravelMode = TravelMode.Driving,
         Waypoints = new List<GeoCoordinate>()
     {
         startPosition, 
         endPosition
     },
         RouteOptimization = RouteOptimization.MinimizeTime
     };
     driverQuery.QueryCompleted += driverRouteQuery_QueryCompleted;
     driverQuery.QueryAsync();
 }
 void Mygeocodequery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
 {
     if (e.Error == null)
     {
         try
         {
             MyQuery = new RouteQuery();
             MyCoordinates.Add(userCoordinate);
             MyCoordinates.Add(nearest.Coordinate);
             MyQuery.TravelMode = TravelMode.Walking;
             MyQuery.Waypoints = MyCoordinates;
             MyQuery.QueryCompleted += MyQuery_QueryCompleted;
             MyQuery.QueryAsync();
             Mygeocodequery.Dispose();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Exemplo n.º 36
0
        /// <summary>
        /// Get the route from me to a friend
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void FriendList_Route(object sender, RoutedEventArgs e)
        {
            try
            {
                //get index
                int selectedIndex = App.ViewModel.Friends.IndexOf((sender as MenuItem).DataContext as Friend);
                Friend friend = App.ViewModel.Friends[selectedIndex];                

                //Add start and end points
                List<GeoCoordinate> MyCoordinates = new List<GeoCoordinate>();
                MyCoordinates.Add(new GeoCoordinate(Me.Latitude, Me.Longitude));
                MyCoordinates.Add(new GeoCoordinate(friend.Latitude, friend.Longitude));

                //send the query
                MyQuery = new RouteQuery();
                MyQuery.Waypoints = MyCoordinates;
                MyQuery.QueryCompleted += MyQuery_QueryCompleted;
                try
                {
                    MyQuery.QueryAsync();
                }
                catch (Exception)
                {
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something gotta wrong.");
            }
        }
Exemplo n.º 37
0
        public DriverItineraryDetails()
        {
            InitializeComponent();

            //hanh trinh chua ai dang ki
            if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CREATED))
            {
                //create button update hanh trinh
                Button btnUpdate = new Button();
                btnUpdate.Content = "Cập Nhật";
                btnUpdate.Click += btnUpdate_Click;
                gridInfo.Children.Add(btnUpdate);
                Grid.SetRow(btnUpdate, 5);

                //create button huy hanh trinh
                Button btnDelete = new Button();
                btnDelete.Content = "Xóa";
                btnDelete.Click += btnDelete_Click;
                gridInfo.Children.Add(btnDelete);
                Grid.SetRow(btnDelete, 6);

                //cho phep sua doi dien di va diem den

            }
            //dang doi driver accept
            else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CUSTOMER_ACCEPTED))
            {
                //tao button accept va button huy customer accept
                //create button accept hanh trinh
                Button btnAccept = new Button();
                btnAccept.Content = "Chấp Nhận";
                btnAccept.Click += btnAccept_Click;
                gridInfo.Children.Add(btnAccept);
                Grid.SetRow(btnAccept, 5);

                //create button reject hanh trinh
                Button btnReject = new Button();
                btnReject.Content = "Từ Chối";
                btnReject.Click += btnReject_Click;
                gridInfo.Children.Add(btnReject);
                Grid.SetRow(btnReject, 6);
            }
            //driver da accepted
            else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_DRIVER_ACCEPTED))
            {
                //
                //create button start hanh trinh
                Button btnStart = new Button();
                btnStart.Content = "Start";
                btnStart.Click += btnStart_Click;
                gridInfo.Children.Add(btnStart);
                Grid.SetRow(btnStart, 6);
            }
            //ongoing
            else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_ONGOING))
            {
                //create button tracking hanh trinh
                Button btnTracking = new Button();
                btnTracking.Content = "Tracking";
                btnTracking.Click += btnTracking_Click;
                gridInfo.Children.Add(btnTracking);
                Grid.SetRow(btnTracking, 6);

                //btn Finish
            }
            //hanh trinh da ket thuc
            else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_FINISHED))
            {

            }

            //draw 2 points on map
            startPointOverlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long));
            wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long));
            mapLayer.Add(startPointOverlay);
            
            endPointOverlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long));
            wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long));
            mapLayer.Add(endPointOverlay);
            
            //set zoom and center point
            mapItineraryDetails.ZoomLevel = 14;
            mapItineraryDetails.Center = startPointOverlay.GeoCoordinate;

            mapItineraryDetails.Layers.Add(mapLayer);

            //draw route
            routeQuery = new RouteQuery();
            //GeocodeQuery Mygeocodequery = null;
            routeQuery.QueryCompleted += routeQuery_QueryCompleted;
            routeQuery.TravelMode = TravelMode.Driving;
            routeQuery.RouteOptimization = RouteOptimization.MinimizeDistance;
            routeQuery.Waypoints = wayPoints;
            routeQuery.QueryAsync();

            //set text 2 points
            txtboxStart.Text = GlobalData.selectedItinerary.start_address;
            txtboxEnd.Text = GlobalData.selectedItinerary.end_address;

            //set text itinerary info

            txtbDistance.Text = GlobalData.selectedItinerary.distance.ToString();
            txtbDescription.Text = GlobalData.selectedItinerary.description;
            txtbCost.Text = GlobalData.selectedItinerary.cost;

            //xu ly ngay thang
            string datetimeString = GlobalData.selectedItinerary.leave_date.Trim();

            DateTime datetime = DateTimes.DatetimeConvert.convertDateTimeFromString(datetimeString);

            datePicker.Value = datetime;
            timePicker.Value = datetime;

            //datePicker.Value = GlobalData.selectedItinerary.da

        }
        /// <summary>
        /// Geo Code Query completed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mygeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {

            if (e.Error == null)
            {
                try
                {
                    myRouteQuery = new RouteQuery();

                    myRouteCoordinates.Add(e.Result[0].GeoCoordinate);

                    myRouteQuery.Waypoints = myRouteCoordinates;

                    myRouteQuery.QueryCompleted += myRouteQuery_QueryCompleted;

                    myRouteQuery.QueryAsync();

                    mygeocodeQuery.Dispose();
                }
                catch (Exception)
                {

                }

            }

        }
Exemplo n.º 39
0
 void walkingRoute(GeoCoordinate currentLocation, GeoCoordinate stopLocation)
 //Get walking route from selected location to selected stop
 {
     if (MyMapRoute != null)
     {
         stopsMap.RemoveRoute(MyMapRoute);
     }
     MarkStopsLocations(ClosestStops);
     List<GeoCoordinate> MyCoordinates = new List<GeoCoordinate>();
     MyCoordinates.Add(currentLocation);
     MyCoordinates.Add(stopLocation);
     RouteQuery WalkingRouteQuery = new RouteQuery();
     WalkingRouteQuery.Waypoints = MyCoordinates;
     WalkingRouteQuery.TravelMode = TravelMode.Walking;
     //progressBar.Visibility = Visibility.Visible;
     progressBar.FlowDirection = System.Windows.FlowDirection.LeftToRight;
     WalkingRouteQuery.QueryCompleted += WalkingRouteQuery_QueryCompleted;
     WalkingRouteQuery.QueryAsync();
 }
Exemplo n.º 40
0
 void Mygeocodequery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
 {
     if (e.Error == null)
     {
         try
         {
             MyQuery = new RouteQuery();
             MyCoordinates.Add(current.getCoordinates());
             MyQuery.Waypoints = MyCoordinates;
             MyQuery.QueryCompleted += MyQuery_QueryCompleted;
             MyQuery.QueryAsync();
             Mygeocodequery.Dispose();
         }
         catch (Exception)
         {
             MessageBox.Show("Не вдалося побудувати маршрут");
         }
     }
 }
Exemplo n.º 41
0
        private void GetCoordinates()
        {
            routeQuery = new RouteQuery();

            /*
            GeoCoordinate currentLocation = new GeoCoordinate(37.7842, -122.4016);
            
            GeocodeQuery startPoint = new GeocodeQuery();
            startPoint.SearchTerm = "Golden Gate Bridge";
            startPoint.GeoCoordinate = currentLocation;
            startPoint.QueryCompleted += geocodequery_QueryCompleted;
            startPoint.QueryAsync();
            pointCount++;
            

            GeocodeQuery endPoint = new GeocodeQuery();
            endPoint.SearchTerm = "Rodeo Beach";
            endPoint.GeoCoordinate = currentLocation;
            endPoint.QueryCompleted += geocodequery_QueryCompleted;
            endPoint.QueryAsync();
            pointCount++;
            */

            GeoCoordinate bridge = new GeoCoordinate(37.7829, -122.4000);
            GeoCoordinate midWay1 = new GeoCoordinate(37.7875, -122.4033);
            GeoCoordinate beach = new GeoCoordinate(37.8092, -122.4164);
            MyCoordinates.Add(bridge);
            MyCoordinates.Add(midWay1);
            MyCoordinates.Add(beach);

            routeQuery.Waypoints = MyCoordinates;
            routeQuery.QueryCompleted += routeQuery_QueryCompleted;
            routeQuery.QueryAsync();

        }
Exemplo n.º 42
0
        private void CreateDirectionsPivotItem()
        {
            var currentPosition = LocationService.CurrentPosition;
            if (currentPosition != null && !currentPosition.IsUnknown && Settings.GetBool(Setting.LocationServicesEnabled))
            {
                var routeQuery = new RouteQuery
                {
                    RouteOptimization = RouteOptimization.MinimizeTime,
                    TravelMode = TravelMode.Walking,
                    Waypoints = new[] {
                    currentPosition,
                    new GeoCoordinate(departuresAndArrivalsTable.Station.Location.Lat, departuresAndArrivalsTable.Station.Location.Long) },
                };

                routeQuery.QueryCompleted += OnRouteQueryCompleted;
                routeQuery.QueryAsync();
            }
        }
        void Mygeocodequery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {
            if (e.Error == null)
            {
                MyQuery = new RouteQuery();
                try
                {
                    coordonnesTrajet.Add(e.Result[0].GeoCoordinate);
                    MyQuery.Waypoints = coordonnesTrajet;
                    MyQuery.QueryCompleted += MyQuery_QueryCompleted;
                    MyQuery.QueryAsync();
                    Mygeocodequery.Dispose();
                }
                catch (ArgumentOutOfRangeException)
                {
                    MessageBox.Show("Impossible de calculer l'itinéraire, veuillez rééssayer plus tard.", "Erreur", MessageBoxButton.OKCancel);

                }
            }
        }
Exemplo n.º 44
0
        void geoWatch_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
        {
            mevcutLokasyon = e.Position.Location;
            if (!SingleTheater)
            {
                myMap.SetView(e.Position.Location, 15);
            }
            else
            {
                collection.Add(e.Position.Location);
                LocationRectangle setRect = null;
                setRect = LocationRectangle.CreateBoundingRectangle(collection); 
                myMap.SetView(setRect);
            }

            //Önce bir kendimizi gösterelim.
            //accuracy hesaplansın
            UpdateAccuracyShow();

            if (MapOverlay_ForMe == null)
            {
                MapOverlay_ForMe = new MapOverlay();
                MapOverlay_ForMe.Content = Pin_ME;
                Pin_ME.RenderTransformOrigin = new Point(0, 0);
                Pin_ME.RenderTransform = new ScaleTransform();
                MapOverlay_ForMe.PositionOrigin = new Point(0, 0);
                MapLayer MyLayer = new MapLayer();
                MyLayer.Add(MapOverlay_ForMe);
                myMap.Layers.Add(MyLayer);
            }                    
            MapOverlay_ForMe.GeoCoordinate = e.Position.Location;

            if (!SingleTheater)
            {
                //Pull nearest theaters if not in "SingleTheater" mode.
                Salonlar yakinSalonlar = new Salonlar();
                yakinSalonlar.getCompleted += yakinSalonlar_getCompleted;
                yakinSalonlar.get(mevcutLokasyon.Latitude, mevcutLokasyon.Longitude);
            }
            else
            {
                //Let's do routing if we are in "SingleTheater" mode.
                if (SingleTheater)
                {
                    RouteQuery newQuery = new RouteQuery();
                    List<GeoCoordinate> MyCoordinates = new List<GeoCoordinate>();
                    MyCoordinates.Add(mevcutLokasyon);
                    MyCoordinates.Add(collection[0]);
                    newQuery.Waypoints = MyCoordinates;
                    newQuery.QueryCompleted += newQuery_QueryCompleted;
                    newQuery.QueryAsync();
                }
            }
        }
Exemplo n.º 45
0
        private void CalcularRota(List<Localizacao> rota)
        {
            List<GeoCoordinate> lst = new List<GeoCoordinate>();

            if (rota != null)
            {
                if (rota.Count != 0)
                {
                    foreach (Localizacao loc in rota)
                    {
                        lst.Add(loc.Coordenada);
                    }
                    RotaQuery = new RouteQuery();
                    RotaQuery.TravelMode = _travelMode;
                    RotaQuery.Waypoints = lst;
                    RotaQuery.QueryCompleted += RotaQuery_QueryCompleted;
                    RotaQuery.QueryAsync();
                }
            }
        }