Search in sources :

Example 1 with LocationClientOption

use of com.baidu.location.LocationClientOption in project wechat by motianhuo.

the class BaiduMapActivity method showMapWithLocationClient.

private void showMapWithLocationClient() {
    mLoadingDialog = new FlippingLoadingDialog(this, "正在确定你的位置...");
    mLoadingDialog.show();
    mLocClient = new LocationClient(this);
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    // 打开gps
    option.setOpenGps(true);
    // option.setCoorType("bd09ll"); //设置坐标类型
    // Johnson change to use gcj02 coordination. chinese national standard
    // so need to conver to bd09 everytime when draw on baidu map
    option.setCoorType("gcj02");
    option.setScanSpan(30000);
    option.setAddrType("all");
    mLocClient.setLocOption(option);
}
Also used : LocationClient(com.baidu.location.LocationClient) FlippingLoadingDialog(com.juns.wechat.dialog.FlippingLoadingDialog) LocationClientOption(com.baidu.location.LocationClientOption)

Example 2 with LocationClientOption

use of com.baidu.location.LocationClientOption 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)

Example 3 with LocationClientOption

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

the class UserDetailFragPresenterImpl method getLocation.

private String getLocation() {
    mLocationClient = new LocationClient(mContext);
    mLocationClient.registerLocationListener((bdLocation) -> {
        mLocation = bdLocation.getAddress().address;
        mUserDetailFragView.updateLocation(mLocation);
        mLocationClient.stop();
    });
    LocationClientOption option = new LocationClientOption();
    //可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    //可选,默认gcj02,设置返回的定位结果坐标系,
    option.setCoorType("gcj02");
    int span = 2000;
    //可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
    option.setScanSpan(span);
    //可选,设置是否需要地址信息,默认不需要
    option.setIsNeedAddress(true);
    //可选,默认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();
    return mLocation;
}
Also used : LocationClient(com.baidu.location.LocationClient) LocationClientOption(com.baidu.location.LocationClientOption)

Example 4 with LocationClientOption

use of com.baidu.location.LocationClientOption in project SmartCampus by Vegen.

the class EaseBaiduMapActivity method showMapWithLocationClient.

private void showMapWithLocationClient() {
    String str1 = getResources().getString(R.string.Making_sure_your_location);
    progressDialog = new ProgressDialog(this);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setMessage(str1);
    progressDialog.setOnCancelListener(new OnCancelListener() {

        public void onCancel(DialogInterface arg0) {
            if (progressDialog.isShowing()) {
                progressDialog.dismiss();
            }
            Log.d("map", "cancel retrieve location");
            finish();
        }
    });
    progressDialog.show();
    mLocClient = new LocationClient(this);
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    // open gps
    option.setOpenGps(true);
    // option.setCoorType("bd09ll");
    // Johnson change to use gcj02 coordination. chinese national standard
    // so need to conver to bd09 everytime when draw on baidu map
    option.setCoorType("gcj02");
    option.setScanSpan(30000);
    option.setAddrType("all");
    mLocClient.setLocOption(option);
}
Also used : LocationClient(com.baidu.location.LocationClient) DialogInterface(android.content.DialogInterface) LocationClientOption(com.baidu.location.LocationClientOption) ProgressDialog(android.app.ProgressDialog) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Aggregations

LocationClient (com.baidu.location.LocationClient)4 LocationClientOption (com.baidu.location.LocationClientOption)4 ProgressDialog (android.app.ProgressDialog)1 DialogInterface (android.content.DialogInterface)1 OnCancelListener (android.content.DialogInterface.OnCancelListener)1 BDLocation (com.baidu.location.BDLocation)1 BDLocationListener (com.baidu.location.BDLocationListener)1 FlippingLoadingDialog (com.juns.wechat.dialog.FlippingLoadingDialog)1