I've got an options menu that allows the user to change map type on google maps. That works fine, but I'd like to offer the functionality to change the markers presently showing which I control with a boolean value. Here is my current code.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.map_styles_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
switch(item.getItemId()) {
case R.id.normal_map:
mapType=GoogleMap.MAP_TYPE_NORMAL;
break;
case R.id.satellite_map:
mapType=GoogleMap.MAP_TYPE_SATELLITE;
break;
case R.id.terrain_map:
mapType=GoogleMap.MAP_TYPE_TERRAIN;
break;
case R.id.hybrid_map:
mapType=GoogleMap.MAP_TYPE_HYBRID;
break;
}
googleMap.setMapType(mapType);
return true;
}
I guess what I'd like to do is create another case statement like so
case R.id.present:
mapChange=true;
break;
case R.id.past:
mapChange=false;
break;
I use items in the menu XML file to represent the maps, could I use items for changing a boolean too?
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/map_types"
android:title="Menu"
android:showAsAction="always">
<menu>
<item android:id="@+id/normal_map"
android:title="Mormal map"/>
<item android:id="@+id/satellite_map"
android:title="Satellite map"/>
<item android:id="@+id/terrain_map"
android:title="Terrain map"/>
<item android:id="@+id/hybrid_map"
android:title="Hybrid map"/>
</menu>
</item>
So I would add an item below the above like
<item android:id="@+id/past"
android:title="Change to past markers"/>