Java源码示例:com.baidu.mapapi.map.MyLocationConfiguration.LocationMode

示例1
private void initLocation() {

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

	}
 
示例2
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	// int id = item.getItemId();
	// if (id == R.id.action_settings) {
	// return true;
	// }

	int item_id = item.getItemId();
	// int isDisplayScreen = getWindow().getAttributes().flags;
	switch (item_id) {
	case R.id.map_common:
		mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);

		break;
	case R.id.map_satellite:
		mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
		break;

	case R.id.map_traffic:
		if (mBaiduMap.isTrafficEnabled()) {
			mBaiduMap.setTrafficEnabled(false);
			item.setTitle("交通地图(on)");
		} else {
			mBaiduMap.setTrafficEnabled(true);
			item.setTitle("交通地图(off)");
		}
		break;

	case R.id.map_heat:

		if (mBaiduMap.isBaiduHeatMapEnabled()) {
			mBaiduMap.setBaiduHeatMapEnabled(false);
			item.setTitle("热力图(on)");
		} else {
			mBaiduMap.setBaiduHeatMapEnabled(true);
			item.setTitle("热力图(off)");
		}

		break;

	case R.id.display_fullscreen:

		if (isDisplayScreen == false) {// 当前非全屏,设置成全屏
			// requestWindowFeature(Window.FEATURE_NO_TITLE);
			// 此处不能取消标题栏,否则会出错;
			getWindow().setFlags(
					WindowManager.LayoutParams.FLAG_FULLSCREEN,
					WindowManager.LayoutParams.FLAG_FULLSCREEN);
			isDisplayScreen = true;
			item.setTitle("关闭全屏");
		} else {// 当前全屏,设置成非全屏
			getWindow().clearFlags(
					WindowManager.LayoutParams.FLAG_FULLSCREEN);
			item.setTitle("打开全屏");
			isDisplayScreen = false;
		}

		break;

	case R.id.id_map_location:
		centerToMyLocation();

		break;

	case R.id.id_map_mode_common:
		mLocationMode = LocationMode.NORMAL;

		break;

	case R.id.id_map_mode_following:
		mLocationMode = LocationMode.FOLLOWING;
		break;

	case R.id.id_map_mode_compass:
		mLocationMode = LocationMode.COMPASS;
		break;

	}
	return super.onOptionsItemSelected(item);
}