3

我无法更改我的 Android 应用程序上的地图类型,一切正常,但此功能不是。

这是 MapActivity 类的一部分

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                                   WindowManager.LayoutParams.FLAG_FULLSCREEN );
    this.locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    mMapFragment = MapFragment.newInstance();
    setContentView(R.layout.activity_map_fabio);
    options.mapType(GoogleMap.MAP_TYPE_NORMAL)
    .compassEnabled(true)
    .scrollGesturesEnabled(true)
    .zoomGesturesEnabled(true)
    .tiltGesturesEnabled(true);
    MapFragment.newInstance(options);
    mMap = ((SupportMapFragment) getSupportFragmentManager()
                                          .findFragmentById(R.id.map)).getMap();
    android.app.FragmentTransaction fragmentTransaction = 
                                        getFragmentManager().beginTransaction();
    fragmentTransaction.add(R.id.map, mMapFragment);

    fragmentTransaction.commit();

    satellite = (CheckBox) findViewById(R.id.satellite);
    satellite.setOnCheckedChangeListener(new OnCheckedChangeListener(){
        @Override
        public void onCheckedChanged(CompoundButton buttonView, 
                                                   boolean isChecked) {
            if (satellite.isChecked()){
                mMap.getUiSettings().setAllGesturesEnabled(true);
                options.mapType(GoogleMap.MAP_TYPE_SATELLITE);                  
            }
        }
    });

会听取检查,但地图不会更改视图。

4

1 回答 1

4

你应该有这个导入:

import static com.google.android.gms.maps.GoogleMap.MAP_TYPE_SATELLITE;

要将地图类型更改为卫星,您应该有以下行:

mMap.setMapType(MAP_TYPE_SATELLITE);
于 2013-06-30T20:43:28.813 回答