TesterABC
TesterABC

Reputation: 1226

Default MapFragment loading instead of written MapsActivity class

I'm new to Android and there is this problem I couldn't resolve for months.I'm using a Map as a Fragment in my navigation drawer and to enable my location I used,mMap.setMyLocationEnabled(true);

So, what I need is to load this MapsActivity as a fragment of My drawer. But, when I run the MapsActivity alone (added <intent-filter> in to MapsActivity) I can see the my Location button and I can click on it.

But, when I run the Drawer and use the MapsActivity as a Fragment, I cannot see the my location button in the map.

Here is the updateDisplay code in my drawer.

  private void updateDisplay(int position) {
        Fragment fragment = null;
        fragment = new MapFragment();

        //getMyLocation();
        // MapsActivity mapsActivity = new MapsActivity();
        //mapsActivity.getMyLocation();


        if (fragment != null) {
            FragmentManager fragmentManager = getFragmentManager();
            fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit();

            // update selected item and title, then close the drawer
            mDrawerLayout.closeDrawer(mLenear);
        }
        else {
            // error in creating fragment
            Log.e("Extract", "Error in creating fragment");
        }
    }

I think, here the default MapFragment is loading other than loading my MapsActivity. (I may be wrong)

Can anyone tell me why I cannot see the changes done in my MapsActivity when I use it as a Fragment? And what should I do to override the MapFragment with my MapsActivity class?

Upvotes: 0

Views: 86

Answers (1)

Android Enthusiast
Android Enthusiast

Reputation: 4950

Try this tutorial for Google Map Fragment guide: https://github.com/codepath/android_guides/wiki/Google-Maps-Fragment-Guide. In this tutorial, you will through the step by step process of getting an embedded Google Map.

Here's the Official Google Documentation for MapFragment https://developers.google.com/android/reference/com/google/android/gms/maps/MapFragment?hl=en. It might help you.

Upvotes: 1

Related Questions