示例#1
0
  private void initLocation() {
    // TODO Auto-generated method stub
    client = new LocationClient(this);
    locationlistener = new Mylocation();
    client.registerLocationListener(locationlistener);
    // 设置location的一些参数
    LocationClientOption option = new LocationClientOption();
    option.setCoorType("bd09ll");
    option.setIsNeedAddress(true); // 获得当前的地址
    option.setOpenGps(true);
    option.setScanSpan(1000);
    client.setLocOption(option); // 设置完成上述功能
    // 初始化图标
    mylocationbitmap = BitmapDescriptorFactory.fromResource(R.drawable.arrow);
    // 初始化 方向传感器
    myorientaion = new MyOrientation(this);
    myorientaion.setChanged(
        new OrientainChanged() {

          @Override
          public void Onchanged(float x) {
            // TODO Auto-generated method stub
            CurrentX = x;
          }
        });
  }
示例#2
0
 @Override
 protected void onStop() {
   // TODO Auto-generated method stub
   super.onStop();
   mapdu.setMyLocationEnabled(false);
   client.stop();
   // 停止方向传感器
   myorientaion.stop();
 }
示例#3
0
 @Override
 protected void onStart() {
   // TODO Auto-generated method stub
   super.onStart();
   mapdu.setMyLocationEnabled(true);
   if (!client.isStarted()) client.start();
   // 开启方向传感器
   myorientaion.start();
 }