Search in sources :

Example 1 with BDLocationListener

use of com.baidu.location.BDLocationListener in project PhotoNoter by yydcdut.

the class CameraPresenterImpl method initLocation.

private void initLocation() {
    mLocationClient = new LocationClient(mContext);
    mLocationClient.registerLocationListener(new BDLocationListener() {

        @Override
        public void onReceiveLocation(BDLocation bdLocation) {
            mLatitude = bdLocation.getLatitude();
            mLongitude = bdLocation.getLongitude();
        }
    });
    LocationClientOption option = new LocationClientOption();
    //可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    //可选,默认gcj02,设置返回的定位结果坐标系,
    option.setCoorType("gcj02");
    int span = 2000;
    //可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
    option.setScanSpan(span);
    //        option.setIsNeedAddress(checkGeoLocation.isChecked());//可选,设置是否需要地址信息,默认不需要
    //可选,默认false,设置是否使用gps
    option.setOpenGps(true);
    //可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果
    option.setLocationNotify(true);
    //可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死
    option.setIgnoreKillProcess(false);
    //可选,默认false,设置是否需要过滤gps仿真结果,默认需要
    option.setEnableSimulateGps(false);
    mLocationClient.setLocOption(option);
    mLocationClient.start();
}
Also used : BDLocation(com.baidu.location.BDLocation) LocationClient(com.baidu.location.LocationClient) BDLocationListener(com.baidu.location.BDLocationListener) LocationClientOption(com.baidu.location.LocationClientOption)

Aggregations

BDLocation (com.baidu.location.BDLocation)1 BDLocationListener (com.baidu.location.BDLocationListener)1 LocationClient (com.baidu.location.LocationClient)1 LocationClientOption (com.baidu.location.LocationClientOption)1