Issue
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.
Solution
You should have this import:
import static com.google.android.gms.maps.GoogleMap.MAP_TYPE_SATELLITE;
For changing map type to satellite you should have this line:
mMap.setMapType(MAP_TYPE_SATELLITE);
Answered By - tony m
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.