zoukankan      html  css  js  c++  java
  • Android_百度地图基本用法1

     1 /*
     2  * 1.将百度地图引入到app中去
     3  * MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(15.0f);
     4    mBaiduMap.setMapStatus(msu);
     5  * 2.实现三种地图:卫星地图,实时交通,普通地图;
     6  * 
     7  * */
     8 public class MainActivity extends Activity {
     9     MapView mapView;
    10     BaiduMap mBaiduMap;
    11     
    12     @Override
    13     protected void onCreate(Bundle savedInstanceState) {
    14         super.onCreate(savedInstanceState);
    15         SDKInitializer.initialize(getApplicationContext());
    16         requestWindowFeature(Window.FEATURE_NO_TITLE);
    17         setContentView(R.layout.fragment_main);
    18         mapView = (MapView) findViewById(R.id.bmapView);
    19         mBaiduMap = mapView.getMap();
    20         // 设置地图标尺500m
    21         MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(15.0f);
    22         mBaiduMap.setMapStatus(msu);
    23 
    24     }
    25 
    26     public void but(View view) {
    27         switch (view.getId()) {
    28         // 普通地图
    29         case R.id.id_map_common:
    30             mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
    31             break;
    32         // 卫星地图
    33         case R.id.id_map_site:
    34             mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
    35             break;
    36         // 交实时通
    37         case R.id.id_map_traffic:
    38             if (mBaiduMap.isTrafficEnabled()) {
    39                 mBaiduMap.setTrafficEnabled(false);
    40                 // item.setTitle("实时交通(off)");
    41             } else {
    42                 mBaiduMap.setTrafficEnabled(true);
    43                 // item.setTitle("实时交通(on)");
    44             }
    45             break;
    46         
    47         }
    48 
    49     }
    50 
    51     @Override
    52     protected void onResume() {
    53 
    54         super.onResume();
    55         mapView.onResume();
    56     }
    57 
    58     
    59 
    60     @Override
    61     protected void onPause() {
    62         // TODO Auto-generated method stub
    63         super.onPause();
    64         mapView.onPause();
    65     }
    66 
    67     @Override
    68     protected void onDestroy() {
    69         // TODO Auto-generated method stub
    70         super.onDestroy();
    71         mapView.onDestroy();
    72     }
    73 
    74     
    75 }
  • 相关阅读:
    测试发帖
    C# 四舍五入算法(转)
    赚钱,爱好,生活
    c# 当前dll目录
    BlogWriter
    调用com+时,提示 0x800706f7,error msg:占位程序接收到错误数据,(本地调用时提示:不支持此接口)
    测试2
    系统架构设计 & 避免循环引用(转载)
    Visual Studio 2008查找替换用的正则
    Myeclipse webinf/lib包加载问题
  • 原文地址:https://www.cnblogs.com/my334420/p/7111778.html
Copyright © 2011-2022 走看看