2

我有一个非常简单的 SupportMapFragment 来显示我在此视图中使用的小型 Google 地图 在此处输入图像描述

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

这是我的 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));
        }
    }
}

这是将 mapFragment 添加到视图的 DialogFragment 的代码:

@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();
        }

    }
4

1 回答 1

6

好的,所以这正盯着我看,很简单

UiSettings settings = getMap().getUiSettings();
            settings.setAllGesturesEnabled(false);
            settings.setMyLocationButtonEnabled(false);
            settings.setZoomControlsEnabled(false);
于 2013-04-25T14:08:56.613 回答