Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make Google Mapview change to fullscreen from a smaller mapview?

I have a Google mapview in the corner of the screen. I want to add an event that makes it go fullscreen with a button on the map interface, and then small screen again with the same button. Any ideas??

Android v4.0.4 Google Map API V2

like image 633
prophetz Avatar asked Mar 06 '13 12:03

prophetz


1 Answers

You could do this by 2 way:

  1. create a new Activity that on the press of a button will start of and will include a full screen map. in this activity create the same button that will bring you back to your original Activity.

  2. you can programaticly change the Layout width a length of you MapFragment in the same window.

second option will be better as you would avoid the screen flickering of new activity loading.

UPDATE:

regarding the second option here is a code i wrote to enlarge map onClick of the map see if this helps you:

 @Override
 public void onMapClick(LatLng point) 
{
    LinearLayout mapFrameLayout = (LinearLayout)findViewById(R.id.mapFrameLayout);

    if (!isMapOpen)     
    {
        LinearLayout.LayoutParams fullMapParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
        if (!isDetailsOpen)
        {
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            fragmentTransaction.hide(closedDetailsFragment).commit();
            mapFrameLayout.setLayoutParams(fullMapParams);
            isMapOpen = true;
            isDetailsOpenWhenOpenedMap = false;
        }
        else
        {
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            fragmentTransaction.hide(openedDetailsFragment).commit();
            mapFrameLayout.setLayoutParams(fullMapParams);
            isMapOpen = true;
            isDetailsOpenWhenOpenedMap = true;
        }
    }
    else
    {
        LinearLayout.LayoutParams defaultMapparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 280);
        mapFrameLayout.setLayoutParams(defaultMapparams);
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        if (isDetailsOpenWhenOpenedMap)
        {
            fragmentTransaction.show(openedDetailsFragment).commit();               
        }
        else
        {
            fragmentTransaction.show(closedDetailsFragment).commit();
        }
        isMapOpen = false;
    }
}

as you see i change the size of the FrameLayout where the map sits, you can put in the same layout your button and place it on the right|top corner for example. when your map will stretch the button will still be at the same right|top corner.

like image 135
Emil Adz Avatar answered Sep 28 '22 06:09

Emil Adz