Codota Logo
LocationClient.setLocOption
Code IndexAdd Codota to your IDE (free)

How to use
setLocOption
method
in
com.baidu.location.LocationClient

Best Java code snippets using com.baidu.location.LocationClient.setLocOption (Showing top 20 results out of 315)

  • Common ways to obtain LocationClient
private void myMethod () {
LocationClient l =
  • Codota IconContext context;new LocationClient(context)
  • Codota IconEaseBaiduMapActivity easeBaiduMapActivity;new LocationClient(easeBaiduMapActivity)
  • Codota IconContext context;new LocationClient(context.getApplicationContext())
  • Smart code suggestions by Codota
}
origin: dudu90/RxLocation

@Override
public void setOption(final @NonNull ClientOption option) {
  if (option == null) {
    throw new IllegalArgumentException("Option can't be null.");
  }
  mBdlocationClient.setLocOption(option.getBaiduOption());
}
origin: gaolhjy/enjoyshop

public boolean setLocationOption(LocationClientOption option){
  boolean isSuccess = false;
  if(option != null){
    if(client.isStarted())
      client.stop();
    DIYoption = option;
    client.setLocOption(option);
  }
  return isSuccess;
}

origin: gaolhjy/enjoyshop

public LocationService(Context locationContext){
  synchronized (objLock) {
    if(client == null){
      client = new LocationClient(locationContext);
      client.setLocOption(getDefaultLocationClientOption());
    }
  }
}

origin: Rachel-Ding/Android-Tiny-Projects

/***
 * 
 * @param locationContext
 */
public LocationService(Context locationContext){
  synchronized (objLock) {
    if(client == null){
      client = new LocationClient(locationContext);
      client.setLocOption(getDefaultLocationClientOption());
    }
  }
}

origin: Rachel-Ding/Android-Tiny-Projects

/***
 * 
 * @param option
 * @return isSuccessSetOption
 */
public boolean setLocationOption(LocationClientOption option){
  boolean isSuccess = false;
  if(option != null){
    if(client.isStarted())
      client.stop();
    DIYoption = option;
    client.setLocOption(option);
  }
  return isSuccess;
}

origin: zhuhaoHappig/BaiduMapApi

@Override
protected void onCreate(Bundle savedInstanceState) {
  // TODO Auto-generated method stub
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_sdk);
  initView();
  mLocationClient = new LocationClient(getApplication());
  mLocationClient.setLocOption(getDefaultLocationClientOption());
  mLocationClient.registerLocationListener(mListener);
}
origin: huangfangyi/YiChat

private void InitLocation() {
  LocationClientOption option = new LocationClientOption();
  option.setLocationMode(tempMode);//
  option.setCoorType(tempcoor);//
  int span = 1000;
  option.setScanSpan(span);//
  option.setIsNeedAddress(true);
  mLocationClient.setLocOption(option);
}
origin: huangfangyi/FanXin

private void InitLocation() {
  LocationClientOption option = new LocationClientOption();
  option.setLocationMode(tempMode);//
  option.setCoorType(tempcoor);//
  int span = 1000;
  //
  option.setScanSpan(span);//
  option.setIsNeedAddress(true);
  mLocationClient.setLocOption(option);
}
origin: myxh/CoolShopping

private void initLocation() {
  mClientOpt = new LocationClientOption();
  mClientOpt.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);//高精度
  mClientOpt.setCoorType("bd09ll");//设置返回的定位结果坐标系
  mClientOpt.setScanSpan(3000);//设置发起定位请求的时间间隔
  mClientOpt.setIsNeedAddress(true);//设置需要地址信息
  mClientOpt.setOpenGps(true);//设置打开GPS
  mClient.setLocOption(mClientOpt);
}
origin: bigsinger/fakegps

private void autoPositionToCurrentPosition() {
  mLocationClient = new LocationClient(mContent);
  LocationClientOption option = new LocationClientOption();
  option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);//设置定位模式
  option.setOpenGps(true); //是否打开gps
  option.setCoorType("bd09ll");//返回的定位结果是百度经纬度,默认值gcj02
  //当所设的整数值大于等于1000(ms)时,定位SDK内部使用定时定位模式。调用requestLocation( )后,每隔设定的时间,定位SDK就会进行一次定位。
  //当不设此项,或者所设的整数值小于1000(ms)时,采用一次定位模式。
  option.setScanSpan(5000);//设置发起定位请求的间隔时间为5000ms
  option.setIsNeedAddress(true);//返回的定位结果包含地址信息
  option.setNeedDeviceDirect(true);//返回的定位结果包含手机机头的方向
  mLocationClient.setLocOption(option);
  SharedPreferences preferences = MyApp.getSharedPreferences();
  String latitude = preferences.getString("baidulatitude", "");
  String longitude = preferences.getString("baidulongitude", "");
  if (TextUtils.isEmpty(latitude) || TextUtils.isEmpty(longitude)) {
    //自动定位
    mLocationClient.registerLocationListener(myListener);    //注册监听函数
    mLocationClient.start();
    mLocationClient.requestLocation();
  } else {
    //定位到上次选择的位置
    updatePosition(new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude)), true);
  }
}
origin: huangfangyi/FanXin

private void showMapWithLocationClient() {
  mLocClient = new LocationClient(this);
  mLocClient.registerLocationListener(myListener);
  LocationClientOption option = new LocationClientOption();
  option.setOpenGps(true);// open gps
  // 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);
}
origin: myxh/CoolShopping

private void initBaiduMap() {
  //地图初始化
  mBaiduMap = mMapView.getMap();
  //开启定位图层
  mBaiduMap.setMyLocationEnabled(true);
  //定位初始化
  mLocationClient = new LocationClient(this);
  mLocationClient.registerLocationListener(mLocationListener);
  LocationClientOption option = new LocationClientOption();
  option.setOpenGps(true);//打开GPS
  option.setCoorType("bd0911");//设置坐标类型
  option.setScanSpan(1000);
  mLocationClient.setLocOption(option);
  mLocationClient.start();
}
origin: 736008081/frameAndroid

public void initParams(Context context) {
  mLocationClient = new LocationClient(context.getApplicationContext()); // 声明LocationClient类
  if (mMyListener == null) {
    mMyListener = new MyLocationListener(mLocalListener);
  }
  mLocationClient.registerLocationListener(mMyListener); // 注册监听函数
  LocationClientOption option = new LocationClientOption();
  option.setLocationMode(LocationMode.Hight_Accuracy);// 可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
  option.setCoorType("bd09ll");// 可选,默认gcj02,设置返回的定位结果坐标系
  int span = 1000;
  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);// 可选,默认false,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认杀死
  option.SetIgnoreCacheException(false);// 可选,默认false,设置是否收集CRASH信息,默认收集
  option.setEnableSimulateGps(false);// 可选,默认false,设置是否需要过滤gps仿真结果,默认需要
  mLocationClient.setLocOption(option);
}
origin: BaaSBeginner/leanchat-android

private void initBaiduLocClient() {
 locClient = new LocationClient(this.getApplicationContext());
 locClient.setDebug(true);
 LocationClientOption option = new LocationClientOption();
 option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
 option.setScanSpan(5000);
 option.setIsNeedAddress(false);
 option.setCoorType("bd09ll");
 option.setIsNeedAddress(true);
 locClient.setLocOption(option);
 locationListener = new MyLocationListener();
 locClient.registerLocationListener(locationListener);
 locClient.start();
}
origin: yiwent/Mobike

private void initMap() {
  mlocationClient = new LocationClient(this);
  //        mlistener = new MylocationListener();
  //        mlocationClient.registerLocationListener(mlistener);
  LocationClientOption mOption = new LocationClientOption();
  //设置坐标类型
  mOption.setCoorType("bd09ll");
  //设置是否需要地址信息,默认为无地址
  mOption.setIsNeedAddress(true);
  //设置是否打开gps进行定位
  mOption.setOpenGps(true);
  //设置扫描间隔,单位是毫秒 当<1000(1s)时,定时定位无效
  int span = 10000;
  mOption.setScanSpan(span);
  //设置 LocationClientOption
  mlocationClient.setLocOption(mOption);
  if (!mlocationClient.isStarted()) {
    mlocationClient.start();
  }
  UiSettings settings = routeBaiduMap.getUiSettings();
  settings.setScrollGesturesEnabled(true);
}
origin: q422013/IMChat

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_location);
  lat = getIntent().getDoubleExtra("lat", 0);
  lng = getIntent().getDoubleExtra("lng", 0);
  // 地图初始化
  mMapView = (MapView) findViewById(R.id.bmapView);
  mBaiduMap = mMapView.getMap();
  // 开启定位图层
  mBaiduMap.setMyLocationEnabled(true);
  // 定位初始化
  mLocClient = new LocationClient(this);
  mLocClient.registerLocationListener(myListener);
  LocationClientOption option = new LocationClientOption();
  option.setOpenGps(true);// 打开gps
  option.setCoorType("bd09ll"); // 设置坐标类型
  option.setScanSpan(lat != 0 ? 60000 : 1000);
  mLocClient.setLocOption(option);
  mLocClient.start();
}
origin: happyheng/Sport_Android

private void initLocationOption() {
  LocationClientOption option = new LocationClientOption();
  option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy
  );//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
  option.setCoorType("bd09ll");//可选,默认gcj02,设置返回的定位结果坐标系
  option.setScanSpan(LOCATION_SPAN);//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
  option.setIsNeedAddress(true);//可选,设置是否需要地址信息,默认不需要
  option.setOpenGps(true);//可选,默认false,设置是否使用gps
  option.setLocationNotify(false);//可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果
  option.setIsNeedLocationDescribe(true);//可选,默认false,设置是否需要位置语义化结果,可以在BDLocation.getLocationDescribe里得到,结果类似于“在北京天安门附近”
  option.setIsNeedLocationPoiList(true);//可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到
  option.setIgnoreKillProcess(true);//可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死
  option.SetIgnoreCacheException(false);//可选,默认false,设置是否收集CRASH信息,默认收集
  option.setEnableSimulateGps(false);//可选,默认false,设置是否需要过滤gps仿真结果,默认需要
  mLocationClient.setLocOption(option);
}
origin: byhieg/easyweather

private void initLocation() {
  LocationClientOption option = new LocationClientOption();
  option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
  option.setCoorType("bd09ll");//可选,默认gcj02,设置返回的定位结果坐标系
  option.setScanSpan(1000);//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
  option.setIsNeedAddress(true);//可选,设置是否需要地址信息,默认不需要
  option.setOpenGps(true);//可选,默认false,设置是否使用gps
  option.setLocationNotify(true);//可选,默认false,设置是否当GPS有效时按照1S/1次频率输出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仿真结果,默认需要
  MyApplication.getmLocationClient().setLocOption(option);
}
origin: GuoFeilong/LifeHelper

/**
 * init location
 */
private void initLocation(LocationClient locationClient) {
  LocationClientOption option = new LocationClientOption();
  option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy
  );//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
  option.setCoorType("bd09ll");//可选,默认gcj02,设置返回的定位结果坐标系
  int span = 1000;
  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仿真结果,默认需要
  locationClient.setLocOption(option);
}
origin: brainysoon/cyberCar

private void setSometing() {
  //地图初始化
  mBaiduMap = mMapView.getMap();
  //开启定位图层
  mBaiduMap.setMyLocationEnabled(true);
  //定位初始化
  mLocationClient = new LocationClient(this);
  //注册监听事件
  mLocationClient.registerLocationListener(new MyLocationListener());
  //设置
  LocationClientOption option = new LocationClientOption();
  option.setOpenGps(true); //打开GPS
  option.setCoorType("gcj02"); //设置坐标类型
  option.setScanSpan(3000);   //定位间隙
  option.setIsNeedAddress(true);
  //绑定设置
  mLocationClient.setLocOption(option);
  //开始定位
  mLocationClient.start();
  //设置一些 configeration
  mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL,
      true, mNowLoc));
  //初始化Holder
  mDialogHolder = new StationDialogHolder(mDialog);
}
com.baidu.locationLocationClientsetLocOption

Popular methods of LocationClient

  • <init>
  • registerLocationListener
  • start
  • stop
  • unRegisterLocationListener
  • isStarted
  • requestLocation
  • disableLocInForeground
  • enableLocInForeground
  • getLastKnownLocation
  • requestHotSpotState
  • setDebug
  • requestHotSpotState,
  • setDebug

Popular in Java

  • Finding current android device location
  • setScale (BigDecimal)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • runOnUiThread (Activity)
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Dictionary (java.util)
    The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to valu
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Pattern (java.util.regex)
    A compiled representation of a regular expression. A regular expression, specified as a string, must
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now