protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_route_details);

            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
            {
                Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
            }

            var toolbar = (Toolbar)FindViewById(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            var    extras  = Intent.Extras;
            string routeId = extras.GetString(KEY_ROUTE_ID);

            route      = RouteManager.GetRoute(routeId);
            gpsTracker = ExtendedLocationListener.GetInstance();
            gpsTracker.EnableLocationUpdates();
            gpsTracker.EnableCheckForExhibits();
            gpsTracker.SetContext(this);

            if (route != null)
            {
                // getting location

                currentUserLocation = new GeoPoint(gpsTracker.Latitude, gpsTracker.Longitude);


                Title = route.Title;
                InitRouteInfo();
                InitMap();

                AddStartPointOnMap();
                AddViaPointsOnMap();
                AddFinalPointOnMap();

                DrawPathOnMap();

                map.OverlayManager.Add(mapMarkerItemizedOverlay);
            }
            else
            {
                Toast.MakeText(this, Resource.String.empty_route, ToastLength.Short).Show();
            }

            Button button = (Button)this.FindViewById(Resource.Id.routeDetailsStartNavigationButton);

            button.Click += (sender, args) => {
                Intent intent = new Intent(this, typeof(RouteNavigationActivity));
                intent.PutExtra(RouteNavigationActivity.IntentRoute, route.Id);
                StartActivity(intent);
            };

            View view = this.FindViewById(Resource.Id.routedetails_mapview);

            view.ViewTreeObserver.AddOnGlobalLayoutListener(new MapViewGlobalLayoutListener(this));
        }
Exemple #2
0
 private void InitializeExtendedLocationListener()
 {
     extendedLocationListener = ExtendedLocationListener.GetInstance();
     extendedLocationListener.SetContext(this);
     extendedLocationListener.EnableCheckForExhibits();
     extendedLocationListener.EnableLocationUpdates();
     extendedLocationListener.SetExtendedLocationListenerAdapter(this);
 }
        protected override void OnResume()
        {
            base.OnResume();
            gpsTracker = ExtendedLocationListener.GetInstance();
            gpsTracker.SetContext(this);
            gpsTracker.EnableCheckForExhibits();
            gpsTracker.EnableLocationUpdates();

            if (gpsTracker.CanGetLocation)
            {
                currentUserLocation = new GeoPoint(
                    gpsTracker.Latitude, gpsTracker.Longitude);
            }
        }