我尝试在屏幕上创建一个菜单,该菜单将显示卫星模式的地图和地形。
My code:
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_MyLocation:
//startActivity(new Intent(this, MyLocation.class));
return(true);
case MENU_LocationCar:
startActivity(new Intent(this, Gps.class));
return(true);
case MENU_Satellite:
map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
return(true);
case MENU_Terrain:
map.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
return(true);
}
return(super.onOptionsItemSelected(item));
}
您需要刷新MapView
通过调用更改其设置后invalidate()
。
所以你的代码看起来像
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_MyLocation:
//startActivity(new Intent(this, MyLocation.class));
return(true);
case MENU_LocationCar:
startActivity(new Intent(this, Gps.class));
return(true);
case MENU_Satellite:
map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
map.invalidate();
return(true);
case MENU_Terrain:
map.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
map.invalidate();
return(true);
}
return(super.onOptionsItemSelected(item));
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)