Search in sources :

Example 6 with LocationClient

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

Example 7 with LocationClient

use of com.baidu.location.LocationClient in project expression by happy-yuxuan.

the class LocalFragment method findView.

private void findView(View view) {
    et_position = (EditText) view.findViewById(R.id.et_position);
    mMapView = (MapView) view.findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();
    // 声明LocationClient类
    mLocationClient = new LocationClient(getActivity());
    // 注册监听函数
    mLocationClient.registerLocationListener(myListener);
    initLocation();
    // 开启定位
    mLocationClient.start();
    L.e("开始定位");
}
Also used : LocationClient(com.baidu.location.LocationClient)

Example 8 with LocationClient

use of com.baidu.location.LocationClient in project AndroidStudy by tinggengyan.

the class LocationDemo method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_location);
    requestLocButton = (Button) findViewById(R.id.button1);
    mCurrentMode = LocationMode.NORMAL;
    requestLocButton.setText("普通");
    OnClickListener btnClickListener = new OnClickListener() {

        public void onClick(View v) {
            switch(mCurrentMode) {
                case NORMAL:
                    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;
                default:
                    break;
            }
        }
    };
    requestLocButton.setOnClickListener(btnClickListener);
    RadioGroup group = (RadioGroup) this.findViewById(R.id.radioGroup);
    radioButtonListener = new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == R.id.defaulticon) {
                // 传入null则,恢复默认图标
                mCurrentMarker = null;
                mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(mCurrentMode, true, null));
            }
            if (checkedId == R.id.customicon) {
                // 修改为自定义marker
                mCurrentMarker = BitmapDescriptorFactory.fromResource(R.drawable.icon_gcoding);
                mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(mCurrentMode, true, mCurrentMarker, accuracyCircleFillColor, accuracyCircleStrokeColor));
            }
        }
    };
    group.setOnCheckedChangeListener(radioButtonListener);
    // 地图初始化
    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();
    // 开启定位图层
    mBaiduMap.setMyLocationEnabled(true);
    // 定位初始化
    mLocClient = new LocationClient(this);
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    // 打开gps
    option.setOpenGps(true);
    // 设置坐标类型
    option.setCoorType("bd09ll");
    option.setScanSpan(1000);
    mLocClient.setLocOption(option);
    mLocClient.start();
}
Also used : LocationClient(com.baidu.location.LocationClient) OnCheckedChangeListener(android.widget.RadioGroup.OnCheckedChangeListener) RadioGroup(android.widget.RadioGroup) OnClickListener(android.view.View.OnClickListener) MyLocationConfiguration(com.baidu.mapapi.map.MyLocationConfiguration) LocationClientOption(com.baidu.location.LocationClientOption) MapView(com.baidu.mapapi.map.MapView) View(android.view.View)

Aggregations

LocationClient (com.baidu.location.LocationClient)8 LocationClientOption (com.baidu.location.LocationClientOption)5 BDLocationListener (com.baidu.location.BDLocationListener)2 ProgressDialog (android.app.ProgressDialog)1 DialogInterface (android.content.DialogInterface)1 OnCancelListener (android.content.DialogInterface.OnCancelListener)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 RadioGroup (android.widget.RadioGroup)1 OnCheckedChangeListener (android.widget.RadioGroup.OnCheckedChangeListener)1 BDLocation (com.baidu.location.BDLocation)1 MapView (com.baidu.mapapi.map.MapView)1 MyLocationConfiguration (com.baidu.mapapi.map.MyLocationConfiguration)1 FlippingLoadingDialog (com.juns.wechat.dialog.FlippingLoadingDialog)1