コード例 #1
0
        private async Task GetUserLocation()
        {
            try
            {
                var location = await BingMapsWrapper.GetCurrentPosition();

                Map.Center    = location.Coordinate.Point;
                Map.ZoomLevel = 15;
                UpdateUserLocation(location);
                ShowNewRoute(location);
            }
            catch (GpsNotAllowed)
            {
                await new MessageDialog("No GPS Access!", "GPS not functional!").ShowAsync();
                // TODO take action when no gps
                // TODO show in language which is chosen
            }

            BingMapsWrapper.NotifyOnLocationUpdate(async geoposition =>
            {
                await Dispatcher.TryRunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    UpdateUserLocation(geoposition);
                    ShowNewRoute(geoposition);
                });
            });

            ListenToNextPointOfInterest();
        }
コード例 #2
0
        private async void ListenToNextPointOfInterest()
        {
            var point = GetNextPointOfInterest(true);

            if (point != null)
            {
                await BingMapsWrapper.PointOfInterestEntered(async interest =>
                {
                    await Dispatcher.TryRunAsync(CoreDispatcherPriority.Normal, async() =>
                    {
                        if (interest.IsVisited)
                        {
                            return;
                        }
                        if (interest.GetType() == typeof(PointOfInterest))
                        {
                            var poi = (PointOfInterest)interest;
                            NotificationSystem.NotificationSystem.SenToastificationAsync(poi.GetNotification());
                            NotificationSystem.NotificationSystem.SendVibrationNotificationAsync();
                            var g = new PointDataPage(poi);
                            await g.ShowAsync();
                        }
                        interest.IsVisited = true;
                        ListenToNextPointOfInterest();
                        ShowNewRoute(await BingMapsWrapper.GetCurrentPosition());
                        RouteProgressIO.SaveRouteProgressToFile(route);

                        //@TODO PLACE ON BETER LOCATION OR ON NEW TASK
                        if (point is PointOfInterest)
                        {
                            var icon = _routeIcons[(PointOfInterest)point];
                            if (icon == null)
                            {
                                return;
                            }
                            icon.Image =
                                RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Point visited.png"));
                        }
                    });
                }, point);
            }
            else
            {
                switch (Settings.Language)
                {
                case VVVOnTheWay.Language.ENGLISH:
                    NotificationSystem.NotificationSystem.SenToastificationAsync(
                        new Notification("End of the route.",
                                         "You have reached the end of the route. You can turn in your phone to the VVV employee."));
                    break;

                case VVVOnTheWay.Language.DUTCH:
                    NotificationSystem.NotificationSystem.SenToastificationAsync(
                        new Notification("Einde van de route.",
                                         "U heeft de route afgerond. U kan nu de telefoon inleveren bij de VVV medewerker."));
                    break;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// </summary>
        /// <param name="position"></param>
        private async void ShowNewRoute(Geoposition position)
        {
            var routepoints = new List <Point>();
            var points      = new List <Geopoint> {
                position.Coordinate.Point
            };

            while (true)
            {
                var nextPoint = GetNextPointOfInterest(false, routepoints);
                if (nextPoint == null)
                {
                    break;
                }
                points.Add(nextPoint.Location);
                routepoints.Add(nextPoint);
                if (nextPoint is PointOfInterest)
                {
                    break;
                }
            }
            if (points.Count <= 1)
            {
                if (_routeView != null)
                {
                    Map.Routes.Remove(_routeView);
                }
                return;
            }
            var routeResult = await BingMapsWrapper.GetRouteBetween(points);

            if (routeResult == null)
            {
                return;
            }
            if (_routeView != null)
            {
                Map.Routes.Remove(_routeView);
            }
            double distance = routeResult.LengthInMeters;

            if (distance >= 1000.0)
            {
                textBlock2.Text = Math.Round(distance / 1000.0, 2) + " km";
            }
            else
            {
                textBlock2.Text = distance + " m";
            }
            textBlock1.Text = (Math.Round(distance / 5000) + " : " + Math.Round(distance / 1000 % 5 / 5 * 60));

            //@TODO textblock1 check lang
            _routeView = new MapRouteView(routeResult)
            {
                OutlineColor = Colors.Blue,
                RouteColor   = Colors.Blue
            };
            Map.Routes.Add(_routeView);
        }
コード例 #4
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            route = e.Parameter as Route.Route;
            RouteProgressIO.SaveRouteProgressToFile(route);

            BingMapsWrapper.ClearGeofences();
            await GetUserLocation();

            AddPointsOfInterest();
        }