Java Code Examples for com.baidu.location.LocationClientOption#setScanSpan()
The following examples show how to use
com.baidu.location.LocationClientOption#setScanSpan() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaiduMapSelectPoiFragment.java From BmapLite with GNU General Public License v3.0 | 6 votes |
public void initBaiduSdk() { // 定位初始化 mLocClient = new LocationClient(getActivity()); mLocClient.registerLocationListener(this); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType("gcj02"); option.setOpenGps(true); option.setScanSpan(1000); option.setIsNeedAltitude(true); option.setIsNeedAddress(false); mLocClient.setLocOption(option); MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfiguration(configuration); mLocClient.start(); }
Example 2
Source File: RouteBaiduBusActivity.java From BmapLite with GNU General Public License v3.0 | 6 votes |
public void initLocationSDK() { // 定位初始化 mLocClient = new LocationClient(this); mLocClient.registerLocationListener(this); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType("gcj02"); option.setOpenGps(true); option.setScanSpan(1000); option.setIsNeedAltitude(true); option.setIsNeedAddress(false); mLocClient.setLocOption(option); MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfiguration(configuration); mLocClient.start(); isFirstLoc = false; }
Example 3
Source File: BaiduMapRouteFragment.java From BmapLite with Apache License 2.0 | 6 votes |
public void initLocationSDK() { // 定位初始化 mLocClient = new LocationClient(getActivity()); mLocClient.registerLocationListener(this); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType("gcj02"); option.setOpenGps(true); option.setScanSpan(1000); option.setIsNeedAltitude(true); option.setIsNeedAddress(false); mLocClient.setLocOption(option); MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfiguration(configuration); mLocClient.start(); isFirstLoc = false; }
Example 4
Source File: RouteDetailActivity.java From Mobike with Apache License 2.0 | 6 votes |
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); }
Example 5
Source File: MapActivity.java From foodie-app with Apache License 2.0 | 6 votes |
private void initLocation() { LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy );//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备 option.setCoorType("bd09ll");//可选,默认gcj02,设置返回的定位结果坐标系 int span = 2000; option.setScanSpan(0);//可选,默认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仿真结果,默认需要 mLocationClient.setLocOption(option); }
Example 6
Source File: RouteBaiduBusActivity.java From BmapLite with Apache License 2.0 | 6 votes |
public void initLocationSDK() { // 定位初始化 mLocClient = new LocationClient(this); mLocClient.registerLocationListener(this); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType("gcj02"); option.setOpenGps(true); option.setScanSpan(1000); option.setIsNeedAltitude(true); option.setIsNeedAddress(false); mLocClient.setLocOption(option); MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfiguration(configuration); mLocClient.start(); isFirstLoc = false; }
Example 7
Source File: ShareLocationActivity.java From imsdk-android with MIT License | 6 votes |
private void initLocationClient() { locationClient = new LocationClient(getApplicationContext()); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType(CoordinateType.BD09LL); option.setIsNeedAddress(true); option.setOpenGps(true); option.setLocationNotify(true); option.setNeedDeviceDirect(true); option.setIsNeedLocationDescribe(false); option.setIsNeedLocationPoiList(true); option.setIgnoreKillProcess(true); option.SetIgnoreCacheException(true); option.setEnableSimulateGps(true); //5s发送一次自己的位置 option.setScanSpan(5000); locationClient.setLocOption(option); locationClient.registerLocationListener(this); locationClient.start(); }
Example 8
Source File: MainActivity.java From VirtualLocation with Apache License 2.0 | 6 votes |
/** * iniMap 初始化地图 */ private void iniMap() { LocationClientOption option = new LocationClientOption(); option.setOpenGps(true);// 打开gps option.setCoorType("bd09ll"); // 设置坐标类型 option.setScanSpan(3000); mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL; // 缩放 MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(14.0f); mBaiduMap.setMapStatus(msu); mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(mCurrentMode, true, mCurrentMarker)); mLocClient.setLocOption(option); mLocClient.start(); initOverlay(); // 开启线程,一直修改GPS坐标 LocationUtil.startLocaton(); }
Example 9
Source File: BDLocationService.java From Social with Apache License 2.0 | 6 votes |
private void initLocation(){ 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仿真结果,默认需要 mLocationClient.setLocOption(option); }
Example 10
Source File: BaiduMapFragment.java From BmapLite with GNU General Public License v3.0 | 5 votes |
public void initLocationSdk() { // 定位初始化 mLocClient = new LocationClient(getActivity()); mLocClient.registerLocationListener(this); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setCoorType("gcj02"); option.setOpenGps(true); option.setScanSpan(1000); option.setIsNeedAltitude(true); option.setIsNeedAddress(false); mLocClient.setLocOption(option); MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfiguration(configuration); mLocClient.start(); try { LocationManager locManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); if (!locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { onMessage(getResources().getString(R.string.gps_enabled_false)); } } catch (Exception e) { e.printStackTrace(); } }
Example 11
Source File: BaiduLocation.java From cordova-baidu-location with MIT License | 5 votes |
/** * 配置定位SDK参数 */ private void initLocation(int span) { LocationClientOption option = new LocationClientOption(); // 可选,默认高精度,设置定位模式,高精度,低功耗,仅设备 option.setLocationMode(LocationMode.Hight_Accuracy); // 可选,默认gcj02,设置返回的定位结果坐标系 option.setCoorType("bd09ll"); // 可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的 if (stopListen) option.setScanSpan(0); else option.setScanSpan(span); // 可选,设置是否需要地址信息,默认不需要 // option.setIsNeedAddress(false); // 可选,默认false,设置是否使用gps option.setOpenGps(true); // 可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果 option.setLocationNotify(false); /* 可选,默认false,设置是否需要位置语义化结果, * 可以在BDLocation.getLocationDescribe里得到, * 结果类似于“在北京天安门附近” */ // option.setIsNeedLocationDescribe(true); // 可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到 // option.setIsNeedLocationPoiList(true); // 可选,默认false,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认杀死 // option.setIgnoreKillProcess(false); // 可选,默认false,设置是否收集CRASH信息,默认收集 // option.SetIgnoreCacheException(true); // 可选,默认false,设置是否需要过滤gps仿真结果,默认需要 // option.setEnableSimulateGps(false); mLocationClient.setLocOption(option); }
Example 12
Source File: LocationUtils.java From WayHoo with Apache License 2.0 | 5 votes |
private LocationClientOption getLocationClientOption(Context context) { LocationClientOption option = new LocationClientOption(); option.setOpenGps(true); option.setLocationMode(LocationMode.Hight_Accuracy);// 设置定位模式 option.setCoorType("gcj02");// 返回的定位结果是百度经纬度,默认值gcj02 option.setScanSpan(1000);// 设置发起定位请求的间隔时间为1000ms option.setProdName(context.getPackageName()); option.setIsNeedAddress(true); return option; }
Example 13
Source File: LocationUtil.java From apollo-DuerOS with Apache License 2.0 | 5 votes |
private LocationClientOption initLocationOption() { LocationClientOption option = new LocationClientOption(); // optional,default is high accuracy. low power ,only on the device option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); // optional,default is gcj02,later can return converted coordinate system type option.setCoorType("gcj02"); // optional,default is 0,only location once, // it is work when inteval time between location request is greater than or equal to 1000ms option.setScanSpan(SPAN_MIL); // optional,default is false option.setIsNeedAddress(false); // optional,default is false,whether use gps option.setOpenGps(true); // optional,default is false,whether output GPS results acording to 1S1 frequency when gps is valid option.setLocationNotify(false); // optional,default is false,whether need the describe of the location option.setIsNeedLocationDescribe(false); // optional,default is false,whether need POI result which can get in BDLocation.getPoiList option.setIsNeedLocationPoiList(false); // optional,default is true,there is a service in the loaction sdk, // and it run in a independent process, whether kill the service when stop option.setIgnoreKillProcess(true); // optional,default is false,whether collect crash info option.SetIgnoreCacheException(false); // optional,default is false,weather filter the result of the gps simulation option.setEnableSimulateGps(true); return option; }
Example 14
Source File: LocationActivity.java From Conquer with Apache License 2.0 | 5 votes |
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); } }
Example 15
Source File: EaseBaiduMapActivity.java From Social with Apache License 2.0 | 5 votes |
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(); option.setOpenGps(true);// 打开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); }
Example 16
Source File: HomePresenter.java From easyweather with MIT License | 5 votes |
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); }
Example 17
Source File: SearchGoodsActivity.java From school_shop with MIT License | 5 votes |
/** * * @author Owater * @createtime 2015-5-10 下午3:30:31 * @Decription 初始化定位 * */ private void initLocation(){ LocationClientOption option = new LocationClientOption(); option.setLocationMode(tempMode);//设置定位模式 option.setCoorType(tempcoor);//返回的定位结果是百度经纬度,默认值gcj02 int span=1000; option.setScanSpan(span);//设置发起定位请求的间隔时间为5000ms mLocationClient.setLocOption(option); }
Example 18
Source File: LocationUtils.java From SmartOrnament with Apache License 2.0 | 4 votes |
private void initLocation() { LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy );//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备 option.setCoorType("bd09ll");//可选,默认gcj02,设置返回的定位结果坐标系 int span=100; option.setScanSpan(span);//大于等于1000ms时,使用定时定位模式。调用requestLocation()后,每隔设定的时间定定一次位 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仿真结果,默认需要 mLocationClient.setLocOption(option); mLocationClient.registerLocationListener(new BDLocationListener() { @Override public void onReceiveLocation(BDLocation location) { //Receive Location StringBuffer sb = new StringBuffer(256); sb.append("定位时间: "); sb.append(location.getTime()); sb.append(",纬度: "); sb.append(location.getLatitude()); sb.append(",经度: "); sb.append(location.getLongitude()); sb.append(",定位精度: "); sb.append(location.getRadius()+"米;"); if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果 /* sb.append(";我的速度"); sb.append(location.getSpeed());// 单位:公里每小时*/ // sb.append("\nsatellite : "); // sb.append(location.getSatelliteNumber()); // sb.append("\nheight : "); // sb.append(location.getAltitude());// 单位:米 // sb.append("\ndirection : "); // sb.append(location.getDirection());// 单位度 sb.append("所在地址: "); sb.append(location.getAddrStr()); sb.append(";定位方式: "); sb.append("gps定位成功"); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果 sb.append("所在位置: "); sb.append(location.getAddrStr()); //运营商信息 // sb.append("\noperationers : "); // sb.append(location.getOperators()); // sb.append(";定位方式: "); // sb.append("网络定位成功"); } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果 // sb.append(";定位方式: "); // sb.append("离线定位成功,离线定位结果也是有效的"); } else if (location.getLocType() == BDLocation.TypeServerError) { // sb.append(";定位方式: "); // sb.append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { /* sb.append(";定位方式: : "); sb.append("网络不同导致定位失败,请检查网络是否通畅");*/ } else if (location.getLocType() == BDLocation.TypeCriteriaException) { // sb.append(";定位方式:"); // sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); } sb.append(";位置描述: "); sb.append(location.getLocationDescribe());// 位置语义化信息 // List<Poi> list = location.getPoiList();// POI数据 // if (list != null) { // sb.append("\npoilist size = : "); // sb.append(list.size()); // for (Poi p : list) { // sb.append("\npoi= : "); // sb.append(p.getId() + " " + p.getName() + " " + p.getRank()); // } // } editor.putString("location",sb.toString()).commit(); Log.i("111111111111",sb.toString()); // Toast.makeText(context, prefs.getString("location",""), Toast.LENGTH_LONG).show(); } }); }
Example 19
Source File: FakeWeiBoActivity.java From AndroidAnimationExercise with Apache License 2.0 | 4 votes |
private void initLocationAndSearch() { //location mLocationClient = new LocationClient(getApplicationContext()); //声明LocationClient类 mLocationClient.registerLocationListener(this); //注册监听函数 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有效时按照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仿真结果,默认需要 mLocationClient.setLocOption(option); //search mPoiSearch = PoiSearch.newInstance(); mPoiSearch.setOnGetPoiSearchResultListener(new MyPoiSearchListener()); mNearbySearchOption = new PoiNearbySearchOption() .radius(5000) .pageNum(1) .pageCapacity(20) .sortType(PoiSortType.distance_from_near_to_far); //////////////// mGeoCoder = GeoCoder.newInstance(); mGeoCoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() { @Override public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) { Log.e(TAG, "onGetGeoCodeResult: " + geoCodeResult.toString()); } @Override public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) { Log.e(TAG, "onGetReverseGeoCodeResult: " + reverseGeoCodeResult.toString()); } }); }
Example 20
Source File: MapService.java From MapForTour with MIT License | 4 votes |
void initializeService() { /**-------------定位---------------*/ locationListener = new MyLocationListener(); mLocationClient = new LocationClient(getApplicationContext()); //声明LocationClient类 mLocationClient.registerLocationListener(locationListener); //注册监听函数 LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备 int span = 5000; 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.setCoorType("bd09ll"); mLocationClient.setLocOption(option); /**-------------周边雷达---------------*/ //实例化 radarSearchManager = RadarSearchManager.getInstance(); radarNearbyOption = new RadarNearbySearchOption(); radarNearbyOption.pageCapacity(50); radarNearbyOption.sortType(RadarNearbySearchSortType.distance_from_far_to_near); radarNearbyOption.pageNum(0); radarNearbyOption.radius(5000); /**-------------鹰眼轨迹--------------*/ //实例化轨迹服务客户端 lbsTraceClient = new LBSTraceClient(getApplicationContext()); // 设置定位模式 lbsTraceClient.setLocationMode(LocationMode.High_Accuracy); //位置采集周期 int gatherInterval = 5; //打包周期 int packInterval = 30; //设置位置采集和打包周期 lbsTraceClient.setInterval(gatherInterval, packInterval); //轨迹服务类型(0 : 不上传位置数据,也不接收报警信息; 1 : 不上传位置数据,但接收报警信息;2 : 上传位置数据,且接收报警信息) traceType = 2; //轨迹监听器 myOnTrackListener = new MyOnTrackListener(); lbsTraceClient.setOnTrackListener(myOnTrackListener); /**-------------地理围栏---------------*/ //OnTrackListener接口的实现类,实现轨迹监听器回调方法 //轨迹服务中地理围栏监听器 myOnGeoFenceListener = new MyOnGeoFenceListener(); //Entity监听器 myOnEntityListener = new MyOnEntityListener(); lbsTraceClient.setOnGeoFenceListener(myOnGeoFenceListener); lbsTraceClient.setOnEntityListener(myOnEntityListener); /**--------------广播------------------*/ mLocalBroadcastManager = LocalBroadcastManager.getInstance(this); myServiceReceiver = new myServiceReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("cc.bitlight.broadcast.service.start"); intentFilter.addAction("cc.bitlight.broadcast.service.stop"); intentFilter.addAction("cc.bitlight.broadcast.track.queryhistorytrack"); intentFilter.addAction("cc.bitlight.broadcast.geofence.query"); intentFilter.addAction("cc.bitlight.broadcast.mytemp"); mLocalBroadcastManager.registerReceiver(myServiceReceiver, intentFilter); }