Example #1
0
        private void switchtoMap()
        {
            updateToggle.Visibility = ViewStates.Invisible;
            Fab2.SetVisibility(ViewStates.Visible);

            // Removing other fragments

            /*  foreach (Android.App.Fragment f in FragmentList)
             * {
             *    fm.BeginTransaction().Hide(f).Commit();
             *    fm.BeginTransaction().Remove(f).Commit();
             * }*/

            Android.App.FragmentTransaction t = FragmentManager.BeginTransaction();
            //t.Replace(Resource.Id.content_frame, mapFrag);
            //  t.AddToBackStack(null);

            foreach (Android.App.Fragment f in FragmentList)
            {
                if (f != mapFrag)
                {
                    t.Hide(f);
                }
            }

            t.Show(mapFrag);
            t.Commit();

            // Getting the map
            mapFrag.GetMapAsync(this);

            // Showing the map fragment
            // fm.BeginTransaction().Show(mapFrag).Commit();

            // If location isn't null AND map has been initialized (the location service can start updating before
            Location location = LocationServices.FusedLocationApi.GetLastLocation(apiClient);

            if (location != null && MyMap != null)
            {
                CameraUpdate center = CameraUpdateFactory.NewLatLng(new LatLng(location.Latitude, location.Longitude));
                MyMap.MoveCamera(center);
            }
        }
Example #2
0
        private void switchtoSensorFragment()
        {
            updateToggle.Visibility = ViewStates.Invisible;
            Fab2.SetVisibility(ViewStates.Invisible);

            Android.App.FragmentTransaction t = FragmentManager.BeginTransaction();
            t.Replace(Resource.Id.content_frame, senFrag);

            foreach (Android.App.Fragment f in FragmentList)
            {
                if (f != senFrag)
                {
                    t.Hide(f);
                }
            }

            t.Show(senFrag);
            t.Commit();


            //  fm.BeginTransaction().Replace(Resource.Id.content_frame, senFrag).Commit();
            //  fm.BeginTransaction().Show(senFrag).Commit();
        }