@Override
 protected void onDestroy() {
   // 退出时销毁定位
   if (mLocClient != null) mLocClient.stop();
   mMapView.destroy();
   super.onDestroy();
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d("qianjin", "qianjin");
    super.onCreate(savedInstanceState);
    /**
     * 使用地图sdk前需先初始化BMapManager. BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
     * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
     */
    DemoApplication app = (DemoApplication) this.getApplication();
    if (app.mBMapManager == null) {
      app.mBMapManager = new BMapManager(getApplicationContext());
      /** 如果BMapManager没有初始化则初始化BMapManager */
      app.mBMapManager.init(new DemoApplication.MyGeneralListener());
    }
    setContentView(R.layout.activity_locationoverlay);
    CharSequence titleLable = "定位功能";
    setTitle(titleLable);
    requestLocButton = (Button) findViewById(R.id.button1);
    mCurBtnType = E_BUTTON_TYPE.LOC;
    OnClickListener btnClickListener =
        new OnClickListener() {
          public void onClick(View v) {
            switch (mCurBtnType) {
              case LOC:
                // 手动定位请求
                requestLocClick();
                break;
              case COMPASS:
                myLocationOverlay.setLocationMode(LocationMode.NORMAL);
                requestLocButton.setText("定位");
                mCurBtnType = E_BUTTON_TYPE.LOC;
                break;
              case FOLLOW:
                myLocationOverlay.setLocationMode(LocationMode.COMPASS);
                requestLocButton.setText("罗盘");
                mCurBtnType = E_BUTTON_TYPE.COMPASS;
                break;
            }
          }
        };
    requestLocButton.setOnClickListener(btnClickListener);

    RadioGroup group = (RadioGroup) this.findViewById(R.id.radioGroup);
    radioButtonListener =
        new OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == R.id.defaulticon) {
              // 传入null则,恢复默认图标
              modifyLocationOverlayIcon(null);
            }
            if (checkedId == R.id.customicon) {
              // 修改为自定义marker
              modifyLocationOverlayIcon(getResources().getDrawable(R.drawable.icon_geo));
            }
          }
        };
    group.setOnCheckedChangeListener(radioButtonListener);

    // 地图初始化
    mMapView = (MyLocationMapView) findViewById(R.id.bmapView);
    mMapController = mMapView.getController();
    mMapView.getController().setZoom(14);
    mMapView.getController().enableClick(true);
    mMapView.setBuiltInZoomControls(true);
    // 创建 弹出泡泡图层
    createPaopao();

    // 定位初始化
    mLocClient = new LocationClient(this);
    locData = new LocationData();
    Log.v("qianjin", "qianjin");
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true); // 打开gps
    option.setCoorType("bd09ll"); // 设置坐标类型
    option.setScanSpan(1000);
    mLocClient.setLocOption(option);
    mLocClient.start();

    // 定位图层初始化
    myLocationOverlay = new locationOverlay(mMapView);
    // 设置定位数据
    myLocationOverlay.setData(locData);
    // 添加定位图层
    mMapView.getOverlays().add(myLocationOverlay);
    myLocationOverlay.enableCompass();
    // 修改定位数据后刷新图层生效
    mMapView.refresh();
  }
 @Override
 protected void onRestoreInstanceState(Bundle savedInstanceState) {
   super.onRestoreInstanceState(savedInstanceState);
   mMapView.onRestoreInstanceState(savedInstanceState);
 }
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   mMapView.onSaveInstanceState(outState);
 }
 @Override
 protected void onResume() {
   mMapView.onResume();
   super.onResume();
 }
 @Override
 protected void onPause() {
   mMapView.onPause();
   super.onPause();
 }
 /**
  * 修改位置图标
  *
  * @param marker
  */
 public void modifyLocationOverlayIcon(Drawable marker) {
   // 当传入marker为null时,使用默认图标绘制
   myLocationOverlay.setMarker(marker);
   // 修改图层,需要刷新MapView生效
   mMapView.refresh();
 }