Java Code Examples for com.baidu.location.BDLocation#setLongitude()
The following examples show how to use
com.baidu.location.BDLocation#setLongitude() .
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: BDLocationUtil.java From DoraemonKit with Apache License 2.0 | 5 votes |
public static BDLocation proxy(BDLocation bdLocation) { if (GpsMockManager.getInstance().isMocking()) { try { bdLocation.setLatitude(GpsMockManager.getInstance().getLatitude()); bdLocation.setLongitude(GpsMockManager.getInstance().getLongitude()); } catch (Exception e) { e.printStackTrace(); } } return bdLocation; }
Example 2
Source File: LocationAccessAdapter.java From AssistantBySDK with Apache License 2.0 | 5 votes |
public void setAddress(Address address) { if (address != null) { mAddress = address.clone(); BDLocation bdLocation = new BDLocation(); bdLocation.setLatitude(mAddress.getLatitude()); bdLocation.setLongitude(mAddress.getLongitude()); bdLocation = LocationClient.getBDLocationInCoorType(bdLocation, BDLocation.BDLOCATION_BD09LL_TO_GCJ02); mAddress.setLatitude(bdLocation.getLatitude()); mAddress.setLongitude(bdLocation.getLongitude()); } Log.i("LingJu", "LocationAccessAdapter setAddress() 最终位置:>> " + mAddress); }
Example 3
Source File: NaviSetPointPresenter.java From AssistantBySDK with Apache License 2.0 | 5 votes |
@Override public void toHomeNavi() { BDLocation bl = new BDLocation(); bl.setLatitude(address.getLatitude()); bl.setLongitude(address.getLongitude()); // bl = LocationClient.getBDLocationInCoorType(bl, BDLocation.BDLOCATION_GCJ02_TO_BD09LL); double dt = DistanceUtil.getDistance(new LatLng(bl.getLatitude(), bl.getLongitude()), new LatLng(homeAddress.getLatitude(), homeAddress.getLongitude())); if (dt < 50) { mSetPointView.showSnackBar(mAppConfig.getResources().getString(R.string.inHome)); // Toast.makeText(mContext, mAppConfig.getResources().getString(R.string.inHome), Toast.LENGTH_SHORT).show(); }//else if(dt>100000){ // Toast.makeText(mContext, mAppConfig.getResources().getString(R.string.tooLongForCalculate), Toast.LENGTH_SHORT).show(); // } else { //没有网络进行提示 if (NetUtil.getInstance(mContext).getCurrentNetType().equals(NetUtil.NetType.NETWORK_TYPE_NONE)) { final CommonDialog commonDialog = new CommonDialog(mContext, "网络错误", "网络状态不佳,请检查网络设置", "确定"); commonDialog.setOnConfirmListener(new CommonDialog.OnConfirmListener() { @Override public void onConfirm() { commonDialog.cancel(); } }).show(); return; } Intent intent = new Intent(mContext, NaviSetLineActivity.class); intent.putExtra("latitude", homeAddress.getLatitude()); intent.putExtra("longitude", homeAddress.getLongitude()); intent.putExtra("address", homeAddress.getName()); mContext.startActivity(intent); mContext.goInto(); } }
Example 4
Source File: NaviSetPointPresenter.java From AssistantBySDK with Apache License 2.0 | 5 votes |
@Override public void toCompanyNavi() { BDLocation bl = new BDLocation(); bl.setLatitude(address.getLatitude()); bl.setLongitude(address.getLongitude()); // bl = LocationClient.getBDLocationInCoorType(bl, BDLocation.BDLOCATION_GCJ02_TO_BD09LL); double dt = DistanceUtil.getDistance(new LatLng(bl.getLatitude(), bl.getLongitude()), new LatLng(companyAddress.getLatitude(), companyAddress.getLongitude())); if (dt < 50) { mSetPointView.showSnackBar(mAppConfig.getResources().getString(R.string.inCompany)); // Toast.makeText(mContext, mAppConfig.getResources().getString(R.string.inCompany), Toast.LENGTH_SHORT).show(); } else { //没有网络进行提示 if (NetUtil.getInstance(mContext).getCurrentNetType().equals(NetUtil.NetType.NETWORK_TYPE_NONE)) { final CommonDialog commonDialog = new CommonDialog(mContext, "网络错误", "网络状态不佳,请检查网络设置", "确定"); commonDialog.setOnConfirmListener(new CommonDialog.OnConfirmListener() { @Override public void onConfirm() { commonDialog.cancel(); } }).show(); return; } Intent intent = new Intent(mContext, NaviSetLineActivity.class); intent.putExtra("latitude", companyAddress.getLatitude()); intent.putExtra("longitude", companyAddress.getLongitude()); intent.putExtra("address", companyAddress.getName()); mContext.startActivity(intent); mContext.goInto(); } }
Example 5
Source File: BaiduAddress.java From AssistantBySDK with Apache License 2.0 | 5 votes |
/** * 将百度坐标转换成国测局坐标 **/ public void setCGJ02() { BDLocation bl = new BDLocation(); bl.setLatitude(this.latitude); bl.setLongitude(this.longitude); bl = LocationClient.getBDLocationInCoorType(bl, BDLocation.BDLOCATION_BD09LL_TO_GCJ02); this.latitude = bl.getLatitude(); this.longitude = bl.getLongitude(); }
Example 6
Source File: BaiduAddress.java From AssistantBySDK with Apache License 2.0 | 5 votes |
public void setBD09LL() { BDLocation bl = new BDLocation(); bl.setLatitude(this.latitude); bl.setLongitude(this.longitude); bl = LocationClient.getBDLocationInCoorType(bl, BDLocation.BDLOCATION_GCJ02_TO_BD09LL); this.latitude = bl.getLatitude(); this.longitude = bl.getLongitude(); }
Example 7
Source File: NaviConfirmPointActivity.java From AssistantBySDK with Apache License 2.0 | 4 votes |
@OnClick({R.id.ancp_back_bt, R.id.ancp_map_locate_bt, R.id.ancp_zoom_in_bt, R.id.ancp_zoom_out_bt, R.id.ancp_poi_detial_pre_bt, R.id.ancp_poi_detial_next_bt, R.id.ancp_map_its_bt}) public void onClick(View view) { switch (view.getId()) { case R.id.ancp_back_bt: onBackPressed(); break; case R.id.ancp_map_locate_bt: /* 封装定位信息 */ BDLocation location = new BDLocation(); location.setLatitude(address.getLatitude()); location.setLongitude(address.getLongitude()); location.setRadius(address.getRadius()); location.setSpeed(address.getSpeed()); location.setSatelliteNumber(address.getSatelliteNumber()); location = LocationClient.getBDLocationInCoorType(location, BDLocation.BDLOCATION_GCJ02_TO_BD09LL); /* 开启定位图层 */ baiduMap.setMyLocationEnabled(true); // 设置定位图层的配置(定位模式,是否允许方向信息,用户自定义定位图标) baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.FOLLOWING, true, null)); /* 构造定位数据并设置 */ baiduMap.setMyLocationData(new MyLocationData.Builder().latitude(location.getLatitude()) .longitude(location.getLongitude()) .accuracy(location.getRadius()) .direction(location.getDirection()) .satellitesNum(location.getSatelliteNumber()) .speed(location.getSpeed()) .build()); break; case R.id.ancp_zoom_in_bt: baiduMap.setMapStatus(MapStatusUpdateFactory.zoomIn()); break; case R.id.ancp_zoom_out_bt: baiduMap.setMapStatus(MapStatusUpdateFactory.zoomOut()); break; case R.id.ancp_poi_detial_pre_bt: if (mAncpPoiDetailPager.getCurrentItem() > 0 && mAncpPoiDetailPager.getCurrentItem() < list.size()) { showPoiDetail(mAncpPoiDetailPager.getCurrentItem() - 1); } break; case R.id.ancp_poi_detial_next_bt: if (mAncpPoiDetailPager.getCurrentItem() >= 0 && mAncpPoiDetailPager.getCurrentItem() < list.size() - 1) { showPoiDetail(mAncpPoiDetailPager.getCurrentItem() + 1); } break; case R.id.ancp_map_its_bt: if (baiduMap.isTrafficEnabled()) { baiduMap.setTrafficEnabled(false); ((ImageButton) view).setImageResource(R.drawable.bnav_common_ic_map_its_off); } else { baiduMap.setTrafficEnabled(true); ((ImageButton) view).setImageResource(R.drawable.bnav_common_ic_map_its_on); } break; } }
Example 8
Source File: NaviSetLinePresenter.java From AssistantBySDK with Apache License 2.0 | 4 votes |
@Override public void setRouteModeDetail(int index) { calculateScheme = index; cancelCountDownTimer(); /* 设置指定路线 */ BNRoutePlanerProxy.getInstance().selectRoute(index); BNRoutePlanerProxy.getInstance().setCalculateScheme(index); RouteModel.setCalculateScheme(index); /* 获取指定算路偏好的指定路线 */ RoutePlanModelProxy mRoutePlanModel = BNRoutePlanerProxy.getInstance().routePlans.get(calculatePreference).get(index); /* 绑定视图数据 */ mSetLineView.updateRouteDetailList(mRoutePlanModel.getRouteNodeData()); mSetLineView.setLineMsg(mRoutePlanModel); mSetLineView.setLineMsg(mRoutePlanModel); /* 设置导航路线图层 */ BNMapControllerProxy.getInstance().setLayerMode( MapParams.LayerMode.MAP_LAYER_MODE_ROUTE_DETAIL_FOR_NAVI); BNMapControllerProxy.getInstance().updateLayer(MapParams.LayerType.MAP_LAYER_TYPE_ROUTE); //rLineDetailListBox.setVisibility(View.VISIBLE); for (int i = 0; i < 3; i++) { if (i == index) { //选中路线 mSetLineView.setRouteLineModeStyle(i, true); } else { //其他导航路线 mSetLineView.setRouteLineModeStyle(i, false); } } //上传导航引擎对象 com.lingju.context.entity.Address startAddress = getAddress(routeInputs.get(0)); com.lingju.context.entity.Address endAddress = getAddress(routeInputs.get(routeInputs.size() - 1)); List<com.lingju.context.entity.Address> passPoints = new ArrayList<>(); for (int i = 1; i < routeInputs.size() - 1; i++) { passPoints.add(getAddress(routeInputs.get(i))); } RouteModel routeModel = RouteModel.getCurrent(); Route route = getRoute(mRoutePlanModel, startAddress, endAddress, passPoints, routeModel, calculateScheme); mNavigation.setRoute(route); mNavigation.setNaviplan(calculateScheme + 1); mNavigation.setIscongestion(NavigatorService.get().isCongestion() ? "ON" : "OFF"); mNavigation.setStatus(RobotConstant.NaviStatus.PLAN.toString()); uploadNavigation(); keepNavigation(); Log.i(TAG, "第一段路名:" + mRoutePlanModel.getFirstRoadName() + ",时间:" + mRoutePlanModel.getTotalTime() + ",花费:" + mRoutePlanModel.getTollFees() + ",routeNum:" + mRoutePlanModel.getNodeNum() + ",主要道路:" + mRoutePlanModel.getMainRoads()); ArrayList<RoutePlanResultItemProxy> rList = mRoutePlanModel.getRouteNodeData(); BDLocation tt = new BDLocation(); for (RoutePlanResultItemProxy ri : rList) { tt.setLatitude(ri.getLatitude() / 1e5); tt.setLongitude(ri.getLongitude() / 1e5); tt = LocationClient.getBDLocationInCoorType(tt, BDLocation.BDLOCATION_GCJ02_TO_BD09LL); System.out.println(ri.getNextRoadName() + ",condition=" + ri.getRoadCondition() + ",coordinate=[" + tt.getLongitude() + "," + tt.getLatitude() + "]"); } }
Example 9
Source File: NaviSetPointPresenter.java From AssistantBySDK with Apache License 2.0 | 4 votes |
@Override public void initStartAddress() { BDLocation location = new BDLocation(); location.setLatitude(address.getLatitude()); location.setLongitude(address.getLongitude()); location.setRadius(address.getRadius()); location.setSpeed(address.getSpeed()); location.setSatelliteNumber(address.getSatelliteNumber()); // location = LocationClient.getBDLocationInCoorType(location, BDLocation.BDLOCATION_GCJ02_TO_BD09LL); //更新家和公司视图 updateCompany(); updateHome(); final GeoCoder geoCoder = GeoCoder.newInstance(); /* 设置地理编码查询监听者 */ final BDLocation finalLocation = location; geoCoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() { @Override public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) { } @Override public void onGetReverseGeoCodeResult(ReverseGeoCodeResult r) { List<PoiInfo> ls = r.getPoiList(); if (ls != null && ls.size() > 0) { initAddress = new BaiduAddress(); // String myLocation; setBaiduAddressFromPoiInfo(initAddress, ls.get(0)); // myLocation = initAddress.getName(); initAddress.setAddress(address.getAddressDetail()); initAddress.setLatitude(finalLocation.getLatitude()); initAddress.setLongitude(finalLocation.getLongitude()); if (TextUtils.isEmpty(initAddress.getCity())) initAddress.setCity(address.getCity()); BaiduAddress myStartAddr = new BaiduAddress(); myStartAddr.setLatitude(initAddress.getLatitude()); myStartAddr.setLongitude(initAddress.getLongitude()); myStartAddr.setName("我的位置" + "(" + initAddress.getName() + ")" + "附近"); if (mSetPointView.getStartAddrText().startsWith("我的位置")) { myStartAddr.setRemark("出发地"); myStartAddr.setId(null); myStartAddr.setFavoritedTime(null); mAppConfig.startAddress = myStartAddr; } //设置默认回家和去公司的出发地址 // mAppConfig.myAddress = myLocation; // updateCompany(); // updateHome(); //由init进入该方法时不触发导航 updateStart(false); updateEnd(false); updateHistoryList(); geoCoder.destroy(); } } }); geoCoder.reverseGeoCode(new ReverseGeoCodeOption(). location(new LatLng(location.getLatitude(), location.getLongitude()))); }