我在我的Android应用程序中遇到了googleMap.setMapType的问题。我选择googleMap.setMapType在我的主菜单中这个功能对GOOGLE地图没有影响,为什么?
这是我的代码:
public class MainActivity extends FragmentActivity {
private GoogleMap googleMap;
private static final LatLng casa = new LatLng(48.411709,10.971354);
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (googleMap == null) {
googleMap = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
if (googleMap != null) {
googleMap.addMarker(new MarkerOptions().position(casa)
.title("... CASA ...").snippet("LA MIA CASA.")
.draggable(true));
googleMap.setMyLocationEnabled(true);
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(casa, 5));
googleMap.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.mapsat:
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
你有解决方案吗?谢谢!!