从SupportMapFragment中删除按钮覆盖

时间:2013-04-24 20:09:53

标签: android google-maps-android-api-2 supportmapfragment

我有一个非常简单的SupportMapFragment来显示我在此视图中使用的小型Google地图 enter image description here

这个想法是用户可以点击它来查看全屏地图。 如何摆脱地图上的+/-按钮? 如果不可能,是否有其他方法来获取地图?

这是我的MapFragment代码:

public class CustomMapFragment extends SupportMapFragment {
    private static LatLng mPosFija;

    public CustomMapFragment() {
        super();

    }

    public static CustomMapFragment newInstance(LatLng position) {
        CustomMapFragment fragment = new CustomMapFragment();
        mPosFija = position;
        return fragment;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        if (getMap() != null) {
            initMap();
            Log.d(getClass().getSimpleName(), "Map ready for use!");
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        initMap();
    }

    private void initMap() {
        Log.v("CustomMapFragment", "initMap");
        if (getMap() != null) {
            UiSettings settings = getMap().getUiSettings();
            settings.setAllGesturesEnabled(true);
            settings.setMyLocationButtonEnabled(false);

            getMap().clear();
            getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(mPosFija, 5));
            getMap().addMarker(new MarkerOptions().position(mPosFija).draggable(false));
        }
    }
}

这是我的DialogFragment代码,它将mapFragment添加到视图中:

@Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity()) == ConnectionResult.SERVICE_INVALID
                || GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity()) == ConnectionResult.SERVICE_MISSING) {
            Log.e("HERE", "Google play not active");

            TextViewFragment tvf = new TextViewFragment();
            getChildFragmentManager().beginTransaction().replace(R.id.mapview, tvf).commit();

        } else {

            CustomMapFragment mMapFragment = CustomMapFragment.newInstance(new LatLng(offer.latitude, offer.longitude));
            getChildFragmentManager().beginTransaction().replace(R.id.mapview, mMapFragment).commit();
        }

    }

1 个答案:

答案 0 :(得分:6)

好的,所以这就是盯着我看,就像

一样简单
UiSettings settings = getMap().getUiSettings();
            settings.setAllGesturesEnabled(false);
            settings.setMyLocationButtonEnabled(false);
            settings.setZoomControlsEnabled(false);