Java 类com.baidu.mapapi.map.MyLocationConfiguration.LocationMode 实例源码

项目:camera    文件:MainActivity.java   
private void initLocation() {
    // 开启定位图层
    mCurrentMode = LocationMode.NORMAL;
     mBaiduMap
     .setMyLocationConfigeration(new MyLocationConfiguration(
             mCurrentMode, true, null));
    mBaiduMap.setMyLocationEnabled(true);
    // 定位初始化
    mLocClient = new LocationClient(this);
    myListener = new MyLocationListenner();
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true); // 打开gps
    option.setCoorType("bd09ll"); // 设置坐标类型
    option.setScanSpan(20000);
    mLocClient.setLocOption(option);
    mLocClient.start();
}
项目:Tower-develop    文件:BaiduMapFragment.java   
@Override
  public void goToMyLocation() {
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true);
option.setCoorType("bd09ll");
option.setScanSpan(1000);
      option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
mBDLocClient.setLocOption(option);
mBDLocClient.start();
  }
项目:Tower-develop    文件:BaiduMapFragment.java   
private void setupMapUI(BaiduMap map) {
      map.setMyLocationEnabled(true);
      map.setMyLocationConfigeration(new MyLocationConfiguration(LocationMode.NORMAL, true, null));

      mBDLocClient = new LocationClient(getActivity().getApplicationContext());
mBDLocClient.registerLocationListener(mBDLocListener);

      // Hide the zoom control
      map.setViewPadding(0, 0, 0, baseBottomPadding);
      UiSettings mUiSettings = map.getUiSettings();
      mUiSettings.setCompassEnabled(false);
      mUiSettings.setOverlookingGesturesEnabled(false);
      mUiSettings.setZoomGesturesEnabled(true);
      mUiSettings.setRotateGesturesEnabled(mAppPrefs.isMapRotationEnabled());
  }
项目:BaiduMap-TrafficAssistant    文件:MapActivity.java   
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;
                    }
                });

    }
项目:ExcellentWiFi    文件:MapFragment.java   
private void initLocation() {
    // Ĭ��ģʽ
    mLocationMode = LocationMode.NORMAL;

    mLocationClient = new LocationClient(view.getContext());
    // �������
    mLocationListener = new MyLocationListener();
    // ע��
    mLocationClient.registerLocationListener(mLocationListener);
    // ����һЩ��Ҫ������
    setLocationOption();

    // ��ʼ������ͼ��
    mIconLocation = BitmapDescriptorFactory
            .fromResource(R.drawable.map_daohang);

    myOrientationListener = new MyOrientationListener(mContext);
    myOrientationListener
            .setOnOrientationListener(new OnOrientationListener() {

                @Override
                public void onOrientationChanged(float x) {
                    mCurrentX = x;
                }
            });

    mLocationClient.start();
}
项目:FrontOne    文件:MapFragment.java   
public void initMap(){

    mMapView.removeViewAt(1);
    int childCount = mMapView.getChildCount();
    View zoom = null;
    for (int i = 0; i < childCount; i++) {
        View child = mMapView.getChildAt(i);
        if (child instanceof ZoomControls) {
                zoom = child;
                break;
        }
    }
    zoom.setVisibility(View.GONE);

    mBaiduMap.setMyLocationEnabled(true);

    mLocClient = new LocationClient(mContext);
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    option.setOpenGps(true);
    option.setCoorType("bd09ll");
    option.setScanSpan(1000);
    option.setIsNeedAddress(true);
    mLocClient.setLocOption(option);
    mLocClient.start();
}
项目:FrontOne    文件:MainActivity.java   
/**
 * init mapview
 */
public void initMap() {

    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();

    // remove map logo
    mMapView.removeViewAt(1);

    int childCount = mMapView.getChildCount();
    View zoom = null;
    for (int i = 0; i < childCount; i++) {
        View child = mMapView.getChildAt(i);
        if (child instanceof ZoomControls) {
            zoom = child;
            break;
        }
    }
    zoom.setVisibility(View.GONE);

    mBaiduMap = mMapView.getMap();
    UiSettings mUiSettings = mBaiduMap.getUiSettings();
    mUiSettings.setCompassEnabled(false);

    mBaiduMap.setMyLocationEnabled(true);
    mLocClient = new LocationClient(this);
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    option.setOpenGps(true);
    option.setCoorType("bd09ll");
    option.setScanSpan(1000);
    option.setIsNeedAddress(true);
    mLocClient.setLocOption(option);
    mLocClient.start();
}
项目:MapDemo    文件:MainActivity.java   
private void initLocation() {
    locationmode = LocationMode.NORMAL;
    // 声明LocationClient类
    locationClient = new LocationClient(context);
    locationListener = new MyLocationListener();
    // 注册监听函数
    locationClient.registerLocationListener(locationListener);

    // 初始化图标
    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;
                }
            });

    LocationClientOption option = new LocationClientOption();
    // option.setLocationMode(LocationMode.Hight_Accuracy);//
    // 可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
    option.setCoorType("bd09ll");// 可选,默认gcj02,设置返回的定位结果坐标系
    option.setScanSpan(1000);// 可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
    option.setIsNeedAddress(true);// 可选,设置是否需要地址信息,默认不需要
    option.setOpenGps(true);// 可选,默认false,设置是否使用gps
    // option.setLocationNotify(true);//
    // 可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果
    // option.setIsNeedLocationDescribe(true);//
    // 可选,默认false,设置是否需要位置语义化结果,可以在BDLocation.getLocationDescribe里得到,结果类似于“在北京天安门附近”
    // option.setIsNeedLocationPoiList(true);//
    // 可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到
    // option.setIgnoreKillProcess(false);//
    // 可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死
    // option.SetIgnoreCacheException(false);//
    // 可选,默认false,设置是否收集CRASH信息,默认收集
    // option.setEnableSimulateGps(false);// 可选,默认false,设置是否需要过滤gps仿真结果,默认需要
    locationClient.setLocOption(option);
}
项目:MapDemo    文件:MainActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.id_map_common:
        // 普通地图
        mbaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
        break;
    case R.id.id_map_site:
        // 卫星地图
        mbaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
        break;
    case R.id.id_map_traffic:
        // 实时交通图
        if (mbaiduMap.isTrafficEnabled()) {
            mbaiduMap.setTrafficEnabled(false);
            item.setTitle("实时交通(OFF)");
        } else {
            mbaiduMap.setTrafficEnabled(true);
            item.setTitle("实时交通(ON)");
        }
        break;
    case R.id.id_map_location:
        // 我的位置
        centerToMyLocation();
        break;
    case R.id.id_map_mocknav:
        // 模拟导航
        if (mDestLocation != null) {
            routeplanToNavi(false);
        } else {
            Toast.makeText(getApplicationContext(), "请先设置目标", 0).show();
        }
        break;
    case R.id.id_map_realnav:
        // 开始导航
        if (mDestLocation != null) {
            routeplanToNavi(true);
        } else {
            Toast.makeText(getApplicationContext(), "请先设置目标", 0).show();
        }
        break;
    case R.id.id_map_mode_common:
        locationmode = LocationMode.NORMAL;
        break;
    case R.id.id_map_mode_following:
        locationmode = LocationMode.FOLLOWING;
        break;
    case R.id.id_map_mode_compass:
        locationmode = LocationMode.COMPASS;
        break;
    case R.id.id_add_overlay:
        addOverlays(Info.infos);
        break;
    case R.id.id_remove_overlay:
        for (int i = 0; i < list.size(); i++) {
            list.get(i).remove();
        }
        list.clear();
        break;
    case R.id.id_map_hot:
        // 开启交通图
        if (mbaiduMap.isBaiduHeatMapEnabled()) {
            mbaiduMap.setBaiduHeatMapEnabled(false);
            item.setTitle("关闭热力地图(OFF)");
        } else {
            mbaiduMap.setBaiduHeatMapEnabled(true);
            item.setTitle("关闭热力地图(ON)");
        }
        break;
    default:
        break;
    }
    return super.onOptionsItemSelected(item);
}
项目:BaiduMap-TrafficAssistant    文件:MapActivity.java   
@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);
}
项目:EasyTracker    文件:LocationFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    viewMap = inflater
            .inflate(R.layout.activity_location, container, false);

    requestLocButton = (Button) viewMap.findViewById(R.id.button1);
    mCurrentMode = LocationMode.NORMAL;
    requestLocButton.setText("定位");
    OnClickListener btnClickListener = new OnClickListener() {
        public void onClick(View v) {
            switch (mCurrentMode) {
            case NORMAL:
                // Intent intent = new Intent(LocationActivity.this,
                // RoutePlan.class);
                // startActivity(intent);
                // finish();
                requestLocButton.setText("跟随");
                mCurrentMode = LocationMode.FOLLOWING;
                mBaiduMap
                        .setMyLocationConfigeration(new MyLocationConfiguration(
                                mCurrentMode, true, mCurrentMarker));
                break;
            case COMPASS:
                requestLocButton.setText("普通");
                mCurrentMode = LocationMode.NORMAL;
                mBaiduMap
                        .setMyLocationConfigeration(new MyLocationConfiguration(
                                mCurrentMode, true, mCurrentMarker));
                break;
            case FOLLOWING:
                requestLocButton.setText("罗盘");
                mCurrentMode = LocationMode.COMPASS;
                mBaiduMap
                        .setMyLocationConfigeration(new MyLocationConfiguration(
                                mCurrentMode, true, mCurrentMarker));
                break;
            }
        }
    };
    requestLocButton.setOnClickListener(btnClickListener);

    // 地图初始化
    mMapView = (MapView) viewMap.findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();

    bdA = BitmapDescriptorFactory.fromResource(R.drawable.icon_marka);

    bdD = BitmapDescriptorFactory.fromResource(R.drawable.icon_markd);
    // 开启定位图层
    mBaiduMap.setMyLocationEnabled(true);
    // 定位初始化
    mLocClient = new LocationClient(viewMap.getContext());
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true);// 打开gps
    option.setCoorType("bd09ll"); // 设置坐标类型
    option.setScanSpan(1000);
    mLocClient.setLocOption(option);
    mLocClient.start();

    return viewMap;
}
项目:EasyTracker    文件:TrackFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    viewMap = inflater
            .inflate(R.layout.activity_location, container, false);

    requestLocButton = (Button) viewMap.findViewById(R.id.button1);
    mCurrentMode = LocationMode.NORMAL;
    requestLocButton.setText("定位");
    OnClickListener btnClickListener = new OnClickListener() {
        public void onClick(View v) {
            switch (mCurrentMode) {
            case NORMAL:
                // Intent intent = new Intent(LocationActivity.this,
                // RoutePlan.class);
                // startActivity(intent);
                // finish();
                requestLocButton.setText("跟随");
                mCurrentMode = LocationMode.FOLLOWING;
                mBaiduMap
                        .setMyLocationConfigeration(new MyLocationConfiguration(
                                mCurrentMode, true, mCurrentMarker));
                break;
            case COMPASS:
                requestLocButton.setText("普通");
                mCurrentMode = LocationMode.NORMAL;
                mBaiduMap
                        .setMyLocationConfigeration(new MyLocationConfiguration(
                                mCurrentMode, true, mCurrentMarker));
                break;
            case FOLLOWING:
                requestLocButton.setText("罗盘");
                mCurrentMode = LocationMode.COMPASS;
                mBaiduMap
                        .setMyLocationConfigeration(new MyLocationConfiguration(
                                mCurrentMode, true, mCurrentMarker));
                break;
            }
        }
    };
    requestLocButton.setOnClickListener(btnClickListener);

    // 地图初始化
    mMapView = (MapView) viewMap.findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();

    bdA = BitmapDescriptorFactory.fromResource(R.drawable.icon_marka);

    bdD = BitmapDescriptorFactory.fromResource(R.drawable.icon_markd);
    // 开启定位图层
    mBaiduMap.setMyLocationEnabled(true);
    // 定位初始化
    mLocClient = new LocationClient(viewMap.getContext());
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true);// 打开gps
    option.setCoorType("bd09ll"); // 设置坐标类型
    option.setScanSpan(1000);
    mLocClient.setLocOption(option);
    mLocClient.start();
    getMarkerLocation();
    return viewMap;
}
项目:ExcellentWiFi    文件:MapFragment.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // ��ͨ
    case R.id.map_common:
        mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
        break;
    // ����
    case R.id.map_site:
        mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
        break;
    // ʵʱ
    case R.id.map_traffic:
        // �Ƿ���ʾ��ʵʱ��ͼ
        if (mBaiduMap.isTrafficEnabled()) {
            mBaiduMap.setTrafficEnabled(false);
            item.setTitle("ʵʱ��ͨoff");
        } else {
            mBaiduMap.setTrafficEnabled(true);
            item.setTitle("ʵʱ��ͨon");
        }
        break;
    // �ҵ�λ��
    case R.id.map_location:
        centerToMyLocation();
        break;
    // ��ͨģʽ
    case R.id.map_sensormode_normal:
        mLocationMode = LocationMode.NORMAL;
        break;
    // ����ģʽ
    case R.id.map_sensormode_following:
        mLocationMode = LocationMode.FOLLOWING;
        break;
    // ����ģʽ
    case R.id.map_sensormode_compass:
        mLocationMode = LocationMode.COMPASS;
        break;
    // ������
    case R.id.map_add_overlay:
        addOverlay(getMarkerData());
        break;

    default:
        break;
    }
    return super.onOptionsItemSelected(item);
}
项目:Traffic-Boy    文件:NearActivity.java   
@SuppressWarnings("unchecked")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_near);

    allInc = (List<Incident>) getIntent().getBundleExtra("bundle")
            .getSerializable("allInc");

    troubleMaker = new ArrayList<Marker>();
    crowdMaker = new ArrayList<Marker>();
    clearMaker = new ArrayList<Marker>();
    controlMaker = new ArrayList<Marker>();

    initCheckBoxes();

    locationMode = LocationMode.FOLLOWING;
    bitmapDescriptor = null;

    mapView = (MapView) findViewById(R.id.map_near);
    baiduMap = mapView.getMap();

    baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(
            locationMode, true, bitmapDescriptor));

    baiduMap.setMyLocationEnabled(true);
    baiduMap.setOnMarkerClickListener(new OnMarkerClickListener() {

        @Override
        public boolean onMarkerClick(Marker arg0) {

            String type = arg0.getTitle();
            String addr = arg0.getExtraInfo().getString("addr");

            Button bubble = new Button(getApplicationContext());
            bubble.setBackgroundResource(R.drawable.popup);
            bubble.setText("类型:" + type + "\n" + "地点:" + addr);
            InfoWindow window = new InfoWindow(bubble, arg0.getPosition(),
                    -70);
            baiduMap.showInfoWindow(window);
            return true;
        }
    });

    locationClient = new LocationClient(this);
    locationClient.registerLocationListener(new BDLocationListener() {

        @Override
        public void onReceiveLocation(BDLocation location) {
            // TODO Auto-generated method stub
            if (location == null || mapView == null)
                return;
            MyLocationData locationData = new MyLocationData.Builder()
                    .accuracy(location.getRadius()).direction(100)
                    .latitude(location.getLatitude())
                    .longitude(location.getLongitude()).build();
            baiduMap.setMyLocationData(locationData);

            if (isFirstLoc) {
                isFirstLoc = false;
                LatLng ll = new LatLng(location.getLatitude(), location
                        .getLongitude());
                MapStatusUpdate update = MapStatusUpdateFactory
                        .newLatLng(ll);
                baiduMap.animateMapStatus(update);
            }
        }

    });

    LocationClientOption clientOption = new LocationClientOption();
    clientOption.setOpenGps(true);
    clientOption.setCoorType("bd09ll");
    clientOption.setScanSpan(1000);
    locationClient.setLocOption(clientOption);
    locationClient.start();

    addSignals();
}