在卫星和地形模式下查看地图 [英] View map in mode satellite and terrain

查看:88
本文介绍了在卫星和地形模式下查看地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在屏幕上创建一个菜单,该菜单将在卫星模式和地形下显示地图.

I tried to create a menu on the screen, where the menu will display the map in satellite mode and terrain.

我的代码:

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

推荐答案

通过调用invalidate()对其设置进行更改后,需要刷新MapView. 因此您的代码将类似于

You need to refresh the MapView after you make the changes to its settings by calling invalidate(). So your code will look something like

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

这篇关于在卫星和地形模式下查看地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆