use of com.baidu.location.LocationClient in project AndroidStudy by tinggengyan.
the class BaiduLocationUtil method init.
private void init() {
mLocClient = new LocationClient(context.getApplicationContext());
mLocClient.registerLocationListener(new LocationListener());
mLocClient.setLocOption(getLocationClientOption());
mLocClient.start();
}
use of com.baidu.location.LocationClient 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);
}
use of com.baidu.location.LocationClient in project PhotoNoter by yydcdut.
the class CameraPresenterImpl method initLocation.
private void initLocation() {
// todo 封装,把Context弄掉
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();
}
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);
}
use of com.baidu.location.LocationClient in project KL2 by jweihao.
the class BaiduActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 将次此方法写到BaiduApplication中,全局设置。
// SDKInitializer.initialize(getApplicationContext());
mLocationClient = new LocationClient(getApplicationContext());
// 注册一个定位监听器,当获取到位置信息的时候,就会回调这个定位监听器
mLocationClient.registerLocationListener(new MyLocationListener());
setContentView(R.layout.activity_baidu);
mPositionText = (TextView) findViewById(R.id.position_text_view);
mMapView = (MapView) findViewById(R.id.bmapView);
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerview);
// 得到BaiduMap的实例
mBaiduMap = mMapView.getMap();
// 设置Baidu的地图类型,具有MAP_TYPE_NONE、MAP_TYPE_NORMAL和MAP_TYPE_SATELLIT
// mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
mBaiduMap.setMyLocationEnabled(true);
// 运行时权限的获取
initPermissions();
}
Aggregations