Tuesday, April 30, 2013

[android help] Change MapView in GoogleMaps v2 with a checkbox on Android


I can't change the map type on my Android Application, everything work fine but this feature is not.


This is a part of the MapActivity class



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


The check is listened but the map doesn't change the view.



.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...