本文整理汇总了Java中com.baidu.location.LocationClient.requestLocation方法的典型用法代码示例。如果您正苦于以下问题:Java LocationClient.requestLocation方法的具体用法?Java LocationClient.requestLocation怎么用?Java LocationClient.requestLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.baidu.location.LocationClient
的用法示例。
在下文中一共展示了LocationClient.requestLocation方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startPosition
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
public void startPosition() {
mLocationClient = new LocationClient(context);
mMyLocationListener = new MyLocationListener();
mLocationClient.registerLocationListener(mMyLocationListener);
LocationClientOption option = new LocationClientOption();
option.setLocationMode(LocationMode.Hight_Accuracy);//设置定位模式
option.setCoorType("bd09ll");//返回的定位结果是百度经纬度,默认值gcj02
option.setScanSpan(5000);//设置发起定位请求的间隔时间为5000ms
option.setIsNeedAddress(true);//返回的定位结果包含地址信息
option.setNeedDeviceDirect(true);//返回的定位结果包含手机机头的方向
mLocationClient.setLocOption(option);
mLocationClient.start();
if (mLocationClient != null && mLocationClient.isStarted())
mLocationClient.requestLocation();
else
Log.d(TAG, "locClient is null or not started");
}
示例2: getLoc
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
public void getLoc() {
myListener = new MyLocationListener(MapActivity.this,
(MapView)findViewById(R.id.bmapsView));
mLocationClient = new LocationClient(getApplicationContext());
mLocationClient.setAccessKey(mk);
mLocationClient.registerLocationListener(myListener);
LocationClientOption option = new LocationClientOption();
option.setLocationMode(LocationMode.Hight_Accuracy);//设置定位模式
option.setCoorType("bd09ll");//返回的定位结果是百度经纬度,默认值gcj02
option.setScanSpan(5000);
option.setIsNeedAddress(true);//返回的定位结果包含地址信息
option.setNeedDeviceDirect(true);//返回的定位结果包含手机机头的方向
mLocationClient.setLocOption(option);
if (mLocationClient != null && false == mLocationClient.isStarted()) {
mLocationClient.requestLocation();
mLocationClient.start();
}
else
Log.e("LocSDK3", "locClient is null or not started");
}
示例3: location
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
public void location(){
BDLocationListener listener = new MyLocationListener();
//此处需要注意:LocationClient类必须在主线程中声明。需要Context类型的参数。
//Context需要时全进程有效的context,推荐用getApplicationConext获取全进程有效的context
mLocationClient = new LocationClient(getApplicationContext());
//注册位置监听器
mLocationClient.registerLocationListener(listener);
LocationClientOption option = new LocationClientOption();
option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy
);//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
option.setCoorType("bd09ll");//可选,默认gcj02,设置返回的定位结果坐标系
int span = 5000; //5秒发送一次
option.setScanSpan(span);//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
option.setIsNeedAddress(true);//可选,设置是否需要地址信息,默认不需要
option.setOpenGps(true);//可选,默认false,设置是否使用gps
option.setLocationNotify(true);//可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果
option.setIsNeedLocationDescribe(true);//可选,默认false,设置是否需要位置语义化结果,可以在BDLocation.getLocationDescribe里得到,结果类似于“在北京天安门附近”
option.setIsNeedLocationPoiList(true);//可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到
option.setIgnoreKillProcess(false);//可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死
option.SetIgnoreCacheException(false);//可选,默认false,设置是否收集CRASH信息,默认收集
option.setEnableSimulateGps(false);//可选,默认false,设置是否需要过滤gps仿真结果,默认需要
option.setNeedDeviceDirect(true); //返回的定位结果包含手机机头方向
mLocationClient.setLocOption(option);
mLocationClient.start(); //启动位置请求
mLocationClient.requestLocation();//发送请求
}
示例4: initLocClient
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
private void initLocClient() {
//������λͼ��
mBaiduMap.setMyLocationEnabled(true);
mBaiduMap.setMyLocationConfigeration(new MyLocationConfigeration(com.baidu.mapapi.map.MyLocationConfigeration.LocationMode.NORMAL, true, null));
// ��λ��ʼ��
mLocClient = new LocationClient(this);
mLocClient.registerLocationListener(myListener);
LocationClientOption option = new LocationClientOption();
option.setProdName("bmobchat");// ���ò�Ʒ��
option.setOpenGps(true);// ��gps
option.setCoorType("bd09ll"); // ������������
option.setScanSpan(1000);
option.setOpenGps(true);
option.setIsNeedAddress(true);
option.setIgnoreKillProcess(true);
mLocClient.setLocOption(option);
mLocClient.start();
if (mLocClient != null && mLocClient.isStarted())
mLocClient.requestLocation();
if (lastLocation != null) {
// ��ʾ�ڵ�ͼ��
LatLng ll = new LatLng(lastLocation.getLatitude(),
lastLocation.getLongitude());
MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
mBaiduMap.animateMapStatus(u);
}
}
示例5: initLocClient
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
private void initLocClient() {
// 开启定位图层
mBaiduMap.setMyLocationEnabled(true);
mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(
MyLocationConfiguration.LocationMode.NORMAL, true, null));
// 定位初始化
mLocClient = new LocationClient(this);
mLocClient.registerLocationListener(myListener);
LocationClientOption option = new LocationClientOption();
option.setProdName("bmobim");// 设置产品线
option.setOpenGps(true);// 打开gps
option.setCoorType("bd09ll"); // 设置坐标类型
option.setScanSpan(1000);
option.setOpenGps(true);
option.setIsNeedAddress(true);
option.setIgnoreKillProcess(true);
mLocClient.setLocOption(option);
mLocClient.start();
if (mLocClient != null && mLocClient.isStarted())
mLocClient.requestLocation();
if (lastLocation != null) {
// 显示在地图上
LatLng ll = new LatLng(lastLocation.getLatitude(),
lastLocation.getLongitude());
MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
mBaiduMap.animateMapStatus(u);
}
}
示例6: initLocClient
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
private void initLocClient() {
// ������λͼ��
mBaiduMap.setMyLocationEnabled(true);
mBaiduMap.setMyLocationConfigeration(new MyLocationConfigeration(
com.baidu.mapapi.map.MyLocationConfigeration.LocationMode.NORMAL, true, null));
// ��λ��ʼ��
mLocClient = new LocationClient(this);
mLocClient.registerLocationListener(myListener);
LocationClientOption option = new LocationClientOption();
option.setProdName("bmobim");// ���ò�Ʒ��
option.setOpenGps(true);// ��gps
option.setCoorType("bd09ll"); // �����������
option.setScanSpan(1000);
option.setOpenGps(true);
option.setIsNeedAddress(true);
option.setIgnoreKillProcess(true);
mLocClient.setLocOption(option);
mLocClient.start();
if (mLocClient != null && mLocClient.isStarted())
mLocClient.requestLocation();
if (lastLocation != null) {
LatLng ll = new LatLng(lastLocation.getLatitude(),
lastLocation.getLongitude());
MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
mBaiduMap.animateMapStatus(u);
}
}
示例7: initLocClient
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
private void initLocClient() {
// ������λͼ��
mBaiduMap.setMyLocationEnabled(true);
mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(com.baidu.mapapi.map.MyLocationConfiguration.LocationMode.NORMAL, true, null));
// ��λ��ʼ��
mLocClient = new LocationClient(this);
mLocClient.registerLocationListener(myListener);
LocationClientOption option = new LocationClientOption();
option.setProdName("bmobim");// ���ò�Ʒ��
option.setOpenGps(true);// ��gps
option.setCoorType("bd09ll"); // ������������
option.setScanSpan(1000);
option.setOpenGps(true);
option.setIsNeedAddress(true);
option.setIgnoreKillProcess(true);
mLocClient.setLocOption(option);
mLocClient.start();
if (mLocClient != null && mLocClient.isStarted())
mLocClient.requestLocation();
if (lastLocation != null) {
// ��ʾ�ڵ�ͼ��
LatLng ll = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude());
MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
mBaiduMap.animateMapStatus(u);
}
}
示例8: initLocClient
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
private void initLocClient() {
// ������λͼ��
mBaiduMap.setMyLocationEnabled(true);
mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(
com.baidu.mapapi.map.MyLocationConfiguration.LocationMode.NORMAL, true, null));
// ��λ��ʼ��
mLocClient = new LocationClient(this);
mLocClient.registerLocationListener(myListener);
LocationClientOption option = new LocationClientOption();
option.setProdName("bmobim");// ���ò�Ʒ��
option.setOpenGps(true);// ��gps
option.setCoorType("bd09ll"); // ������������
option.setScanSpan(1000);
option.setOpenGps(true);
option.setIsNeedAddress(true);
option.setIgnoreKillProcess(true);
mLocClient.setLocOption(option);
mLocClient.start();
if (mLocClient != null && mLocClient.isStarted())
mLocClient.requestLocation();
if (lastLocation != null) {
// ��ʾ�ڵ�ͼ��
LatLng ll = new LatLng(lastLocation.getLatitude(),
lastLocation.getLongitude());
MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
mBaiduMap.animateMapStatus(u);
}
}
示例9: initLocClient
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
private void initLocClient() {
// 开启定位图层
mBaiduMap.setMyLocationEnabled(true);
mBaiduMap.setMyLocationConfigeration(new MyLocationConfigeration(MyLocationConfigeration.LocationMode.NORMAL,
true, null));
// 定位初始化
mLocClient = new LocationClient(this);
mLocClient.registerLocationListener(myListener);
LocationClientOption option = new LocationClientOption();
option.setProdName("bmobim");// 设置产品线
option.setOpenGps(true);// 打开gps
option.setCoorType("bd09ll"); // 设置坐标类型
option.setScanSpan(1000);
option.setOpenGps(true);
option.setIsNeedAddress(true);
option.setIgnoreKillProcess(true);
mLocClient.setLocOption(option);
mLocClient.start();
if (mLocClient != null && mLocClient.isStarted()) mLocClient.requestLocation();
if (lastLocation != null) {
// 显示在地图上
LatLng ll = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude());
MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
mBaiduMap.animateMapStatus(u);
}
}
示例10: startLocation
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
private void startLocation() {
LocationClient = ((DandelionApplication) getApplication()).mLocationClient;
LocationClient.start();
if (LocationClient != null && LocationClient.isStarted()) {
InitLocation();
LocationClient.requestLocation();
}
}
示例11: onCreate
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 初始化
initEngineManager(this);
// 布局获取ID
setContentView(R.layout.pyp_page_map);
mMapView = (MapView) findViewById(R.id.bmapView);
//实例化监听事件
mMapView.regMapViewListener(mBMapManager, mMapListener);
mMapView.regMapTouchListner(mapTouchListener);
//实例化工具
myLocationOverlay = new MyLocationOverlay(mMapView);
mLocClient = new LocationClient(this.getApplicationContext());
option = new LocationClientOption();
myListener = new MyLocationListenner();
locData = new LocationData();
mLocClient.setAK(APPCodeConst.ak);
mLocClient.registerLocationListener(myListener);
mLocClient.start();
mLocClient.requestLocation();
//对应方法
setOption();
}
示例12: initLocClient
import com.baidu.location.LocationClient; //导入方法依赖的package包/类
private void initLocClient() {
// 开启定位图层
mBaiduMap.setMyLocationEnabled(true);
mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(
com.baidu.mapapi.map.MyLocationConfiguration.LocationMode.NORMAL, true, null));
// 定位初始化
mLocClient = new LocationClient(this);
mLocClient.registerLocationListener(myListener);
LocationClientOption option = new LocationClientOption();
option.setProdName("bmobim");// 设置产品线
option.setOpenGps(true);// 打开gps
option.setCoorType("bd09ll"); // 设置坐标类型
option.setScanSpan(1000);
option.setOpenGps(true);
option.setIsNeedAddress(true);
option.setIgnoreKillProcess(true);
mLocClient.setLocOption(option);
mLocClient.start();
if (mLocClient != null && mLocClient.isStarted())
mLocClient.requestLocation();
if (lastLocation != null) {
// 显示在地图上
LatLng ll = new LatLng(lastLocation.getLatitude(),
lastLocation.getLongitude());
MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
mBaiduMap.animateMapStatus(u);
}
}