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 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("开始定位");
}
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();
}
Aggregations