use of com.baidu.location.BDLocation in project AndroidStudy by tinggengyan.
the class BaiduMapActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_baidumap);
textView = (TextView) findViewById(R.id.textView);
MapView mMapView = (MapView) findViewById(R.id.bmapView);
mapUtil = new BaiduMapUtil(this, mMapView);
locationUtil = new BaiduLocationUtil(this, new BaiduLocationUtil.LocationSuccessListener() {
@Override
public void onReceiveLocation(BDLocation location) {
float accuracy = location.getRadius();
double latitude = location.getLatitude();
double longitude = location.getLongitude();
float direction = location.getDirection();
int satelliteNumber = location.getSatelliteNumber();
float speed = location.getSpeed();
mapUtil.setCurrentLocation(accuracy, direction, longitude, latitude, satelliteNumber, speed);
}
});
findViewById(R.id.refreshLocation).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
locationUtil.requestLocation();
}
});
findViewById(R.id.zoomButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mapUtil.setZoom(18);
}
});
mapUtil.setOnMapStatusChangeListener(new BaiduMapUtil.OnMapStatusChangeListener() {
@Override
public void onMapStatusChangeFinish(final MapStatus mapStatus) {
// TODO: 2017/1/6 根据中心点,获取数据
// 地图操作的中心点。
LatLng target = mapStatus.target;
// 地图操作中心点在屏幕中的坐标
Point targetScreen = mapStatus.targetScreen;
// 地图缩放级别 3~21
float zoom = mapStatus.zoom;
}
});
}
use of com.baidu.location.BDLocation 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();
}
Aggregations