@Override protected void onStop() { super.onStop(); mBaiduMap.setMyLocationEnabled(false); mLocationClient.stop(); myOrientationListener.stop(); }
private void initLocation() { mLocationMode = com.baidu.mapapi.map.MyLocationConfiguration.LocationMode.NORMAL; mLocationClient = new LocationClient(this); mLocationListener = new MyLocationListener(); mLocationClient.registerLocationListener(mLocationListener); LocationClientOption option = new LocationClientOption(); option.setCoorType("bd09ll"); option.setIsNeedAddress(true); option.setOpenGps(true); option.setScanSpan(1000); mLocationClient.setLocOption(option); // 初始化图标 mIconLocation = BitmapDescriptorFactory.fromResource(R.drawable.navi_map_gps_locked); myOrientationListener = new MyOrientationListener(context); myOrientationListener.setOnOrientationListener( new OnOrientationListener() { @Override public void onOrientationChanged(float x) { mCurrentX = x; } }); }