0

I'm using the Google Maps Android API and I'm creating a Map programmatically. However, I can't seem to figure out how to change the layout_height, layout_width, and layout_margin.

I'm looking at the official guide, which says to use GoogleMapOptions, which should give me all the same options as those available via XML.

Here's my code.

            GoogleMapOptions options = new GoogleMapOptions();
            options
                    .compassEnabled(false)
                    .mapToolbarEnabled(false)
                    .rotateGesturesEnabled(false)
                    .scrollGesturesEnabled(false)
                    .tiltGesturesEnabled(false)
                    .zoomControlsEnabled(false)
                    .zoomGesturesEnabled(false);


            MapFragment mMapFragment = MapFragment.newInstance(options);

            FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
            fragmentTransaction.add(R.id.mapMenu, mMapFragment);

            fragmentTransaction.commit();
Ampersand
  • 1
  • 1
  • 1
    You could modify the `mapMenu` item in your layout xml, since that is the container you are using to show the map... – Daniel Nugent Feb 03 '16 at 22:50
  • Yeah, that might be what I'll have to end up doing. Just wanted to see if anyone knew a more direct solution. – Ampersand Feb 03 '16 at 23:03
  • This might work for you: http://stackoverflow.com/questions/21469345/how-do-you-programmatically-change-the-width-height-of-google-maps-v2-support – Daniel Nugent Feb 03 '16 at 23:13
  • That ended up working, other than that getLayoutParams() was returning null, even if I had already added the Fragment to the Activity. I ended up just needed to make new LayoutParams and pass them in. Thanks! – Ampersand Feb 06 '16 at 17:52

0 Answers0