Java Code Examples for com.baidu.location.BDLocation#getAddrStr()
The following examples show how to use
com.baidu.location.BDLocation#getAddrStr() .
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: AddressEditDelegate.java From FastWaiMai with MIT License | 6 votes |
/** * 根据获取到的位置在地图上移动"我"的位置 * * @param location */ private void navigateTo(BDLocation location) { double longitude = location.getLongitude(); double latitude = location.getLatitude(); String address = location.getAddrStr(); if (isFirstLocation) { currentLatLng = new LatLng(latitude, longitude); MapStatus.Builder builder = new MapStatus.Builder(); MapStatus mapStatus = builder.target(currentLatLng).zoom(17.0f).build(); mBaiduMap.animateMapStatus(MapStatusUpdateFactory .newMapStatus(mapStatus)); isFirstLocation = false; //反向地理解析(含有poi列表) mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption() .location(currentLatLng) .radius(radius)); } MyLocationData.Builder locationBuilder = new MyLocationData.Builder(); locationBuilder.latitude(location.getLatitude()); locationBuilder.longitude(location.getLongitude()); MyLocationData locationData = locationBuilder.build(); mBaiduMap.setMyLocationData(locationData); }
Example 2
Source File: LocationDelegate.java From FastWaiMai with MIT License | 6 votes |
@Override public void onReceiveLocation(BDLocation location) { if (location == null){ return; } if (location.getLocType() == BDLocation.TypeGpsLocation || location.getLocType() == BDLocation.TypeNetWorkLocation) { currentAddr = location.getAddrStr(); //当前所在位置 LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude()); mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption() .location(currentLatLng) .radius(radius)); } }
Example 3
Source File: MainActivity.java From BaiDuMapSelectDemo with Apache License 2.0 | 6 votes |
/** * 根据获取到的位置在地图上移动“我”的位置 * * @param location */ private void navigateTo(BDLocation location) { double longitude = location.getLongitude(); double latitude = location.getLatitude(); String address = location.getAddrStr(); if (isFirstLocation) { currentLatLng = new LatLng(latitude, longitude); MapStatus.Builder builder = new MapStatus.Builder(); MapStatus mapStatus = builder.target(currentLatLng).zoom(17.0f).build(); mBaiduMap.animateMapStatus(MapStatusUpdateFactory .newMapStatus(mapStatus)); isFirstLocation = false; //反向地理解析(含有poi列表) mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption() .location(currentLatLng)); } MyLocationData.Builder locationBuilder = new MyLocationData.Builder(); locationBuilder.latitude(location.getLatitude()); locationBuilder.longitude(location.getLongitude()); MyLocationData locationData = locationBuilder.build(); mBaiduMap.setMyLocationData(locationData); }
Example 4
Source File: Activity_Location.java From FoodOrdering with Apache License 2.0 | 6 votes |
private void navigateTo(BDLocation location) { longitude = location.getLongitude(); latitude = location.getLatitude(); tv_longitude.setText(longitude + ""); tv_latitude.setText(latitude + ""); address = location.getAddrStr(); tv_address.setText(address); if (isFirstLocation) { latLng = new LatLng(latitude, longitude); MapStatus.Builder builder = new MapStatus.Builder(); MapStatus mapStatus = builder.target(latLng).zoom(15.0f).build(); mBaiduMap.animateMapStatus(MapStatusUpdateFactory .newMapStatus(mapStatus)); isFirstLocation = false; } MyLocationData.Builder locationBuilder = new MyLocationData.Builder(); locationBuilder.latitude(location.getLatitude()); locationBuilder.longitude(location.getLongitude()); MyLocationData locationData = locationBuilder.build(); mBaiduMap.setMyLocationData(locationData); }
Example 5
Source File: WBPostActivity.java From Simpler with Apache License 2.0 | 6 votes |
@Override public void onReceiveLocation(BDLocation location) { // 在回调方法运行在remote进程 // 获取定位类型 int locType = location.getLocType(); if (locType == BDLocation.TypeGpsLocation || locType == BDLocation.TypeNetWorkLocation || locType == BDLocation.TypeOffLineLocation) { // 定位成功。GPS定位结果 || 网络定位结果 || 离线定位结果 // 纬度 mLatitude = location.getLatitude(); // 经度 mLongitude = location.getLongitude(); // 获取地址信息 mAddrStr = location.getAddrStr(); mHandler.sendEmptyMessage(HANDLE_ADDRESS_OK); } else if (location.getLocType() == BDLocation.TypeServerError) { mHandler.sendEmptyMessage(HANDLE_SERVER_ERROR); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { mHandler.sendEmptyMessage(HANDLE_NETWORK_EXCEPTION); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { mHandler.sendEmptyMessage(HANDLE_CRITERIA_EXCEPTION); } }
Example 6
Source File: LocationService.java From Conquer with Apache License 2.0 | 6 votes |
@Override public void onReceiveLocation(BDLocation location) { L.i(location.getLocType() + "," + +location.getOperators() + "," + location.getLatitude() + "," + location.getLongitude() + "," + location.getAddrStr()); // 成功定位 if (location.getLocType() == 161 || location.getLocType() == 61) { lastPoint = new LocationInfo(location.getLongitude(), location.getLatitude(), location.getAddrStr()); } else {// 定位失败 lastPoint = new LocationInfo(0, 0, "定位失败"); } // 停止定位 mLocationClient.stop(); if (listener != null) { listener.onLocateCompleted(lastPoint); } }
Example 7
Source File: Activity_FoodDelivery.java From FoodOrdering with Apache License 2.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation arg0) { if (arg0.getLocType() == BDLocation.TypeGpsLocation || arg0.getLocType() == BDLocation.TypeNetWorkLocation) { longitude = arg0.getLongitude(); latitude = arg0.getLatitude(); address = arg0.getAddrStr(); // Util.showToast(Activity_FoodDelivery.this,longitude+"/"+latitude+" "+address); } }
Example 8
Source File: MapPickerActivity.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation location) { if (null != location && location.getLocType() != BDLocation.TypeServerError) { // MyLocationData data = new MyLocationData.Builder()// // .direction(mCurrentX)// .accuracy(location.getRadius())// .latitude(location.getLatitude())// .longitude(location.getLongitude())// .build(); mBaiduMap.setMyLocationData(data); // 设置自定义图标 MyLocationConfiguration config = new MyLocationConfiguration( MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfigeration(config); mAddress = location.getAddrStr(); mName = location.getStreet(); mCity = location.getCity(); LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude()); mLoactionLatLng = currentLatLng; // 是否第一次定位 if (isFirstLoc) { isFirstLoc = false; // 实现动画跳转 MapStatusUpdate u = MapStatusUpdateFactory .newLatLng(currentLatLng); mBaiduMap.animateMapStatus(u); mGeoCoder.reverseGeoCode((new ReverseGeoCodeOption()) .location(currentLatLng)); return; } } }
Example 9
Source File: BaiduUtils.java From LocationProvider with Apache License 2.0 | 5 votes |
public static void prinftBDLocation(BDLocation bdLocation) { Log.d("@@@", "====================BDLocation Strat===================="); String str = "BDLocation{" + "locationID='" + bdLocation.getLocationID() + '\'' + ", locType=" + bdLocation.getLocType() + ", locTime='" + bdLocation.getTime() + '\'' + ", latitude=" + bdLocation.getLatitude() + ", longitude=" + bdLocation.getLongitude() + ", radius=" + bdLocation.getRadius() + ", addrStr=" + bdLocation.getAddrStr() + ", country='" + bdLocation.getCountry() + '\'' + ", countryCode='" + bdLocation.getCountryCode() + '\'' + ", city='" + bdLocation.getCity() + '\'' + ", cityCode='" + bdLocation.getCityCode() + '\'' + ", district='" + bdLocation.getDistrict() + '\'' + ", street='" + bdLocation.getStreet() + '\'' + ", streetNumber='" + bdLocation.getStreetNumber() + '\'' + ", locationDescribe='" + bdLocation.getLocationDescribe() + '\'' + ", buildingID='" + bdLocation.getBuildingID() + '\'' + ", buildingName='" + bdLocation.getBuildingName() + '\'' + ", floor='" + bdLocation.getFloor() + '\'' + ", speed=" + bdLocation.getSpeed() + '\'' + ", satelliteNumber=" + bdLocation.getSatelliteNumber() + '\'' + ", altitude=" + bdLocation.getAltitude() + '\'' + ", direction=" + bdLocation.getDirection() + '\'' + ", operators=" + bdLocation.getOperators() + '\'' + "}"; Log.d("@@@", str); Log.d("@@@", "====================BDLocation End===================="); }
Example 10
Source File: LocationActivity.java From Conquer with Apache License 2.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) return; if (lastLocation != null) { if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) { BmobLog.i("获取坐标相同");// 若两次请求获取到的地理位置坐标是相同的,则不再定位 mLocClient.stop(); return; } } lastLocation = location; BmobLog.i("lontitude = " + location.getLongitude() + ",latitude = " + location.getLatitude() + ",地址 = " + lastLocation.getAddrStr()); MyLocationData locData = new MyLocationData.Builder().accuracy(location.getRadius()) // 此处设置开发者获取到的方向信息,顺时针0-360 .direction(100).latitude(location.getLatitude()).longitude(location.getLongitude()).build(); mBaiduMap.setMyLocationData(locData); LatLng ll = new LatLng(location.getLatitude(), location.getLongitude()); String address = location.getAddrStr(); if (address != null && !address.equals("")) { lastLocation.setAddrStr(address); } else { // 反Geo搜索 mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(ll)); } // 显示在地图上 MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); // 设置按钮可点击 // mHeaderLayout.getRightImageButton().setEnabled(true); }
Example 11
Source File: LocationFragment.java From foodie-app with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { mLocation = location.getAddrStr(); PrefUtils.set("user", "location", mLocation, getActivity().getBaseContext()); //Receive Location StringBuffer sb = new StringBuffer(256); sb.append("time : "); sb.append(location.getTime()); sb.append("\nerror code : "); sb.append(location.getLocType()); sb.append("\nlatitude : "); sb.append(location.getLatitude()); sb.append("\nlontitude : "); sb.append(location.getLongitude()); sb.append("\nradius : "); sb.append(location.getRadius()); if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果 sb.append("\nspeed : "); 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("\naddr : "); sb.append(location.getAddrStr()); sb.append("\ndescribe : "); sb.append("gps定位成功"); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果 sb.append("\naddr : "); sb.append(location.getAddrStr()); //运营商信息 sb.append("\noperationers : "); sb.append(location.getOperators()); sb.append("\ndescribe : "); sb.append("网络定位成功"); } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果 sb.append("\ndescribe : "); sb.append("离线定位成功,离线定位结果也是有效的"); } else if (location.getLocType() == BDLocation.TypeServerError) { sb.append("\ndescribe : "); sb.append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { sb.append("\ndescribe : "); sb.append("网络不同导致定位失败,请检查网络是否通畅"); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { sb.append("\ndescribe : "); sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); } sb.append("\nlocationdescribe : "); 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()); } } Log.i("BaiduLocationApiDem", sb.toString()); }
Example 12
Source File: NfcDeviceFragment.java From ESeal with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // TODO Auto-generated method stub if (null != location && location.getLocType() != BDLocation.TypeServerError) { String time = location.getTime(); double lat = location.getLatitude(); double lng = location.getLongitude(); String address = location.getAddrStr() + ", " + lat + "," + lng; // String address = lat + "," + lng; switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockTime.setText(time); lockLocation.setText(address); break; case STATE_OPERATION_UNLOCK: //解封 unlockTime.setText(time); unlockLocation.setText(address); break; case STATE_OPERATION_SETTING: //配置 coordinateSetting = lat + "," + lng; break; } } else if (null != location && location.getLocType() == BDLocation.TypeServerError) { switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockLocation.setText(getString(R.string.fail_get_current_location)); break; case STATE_OPERATION_UNLOCK: //解封 unlockLocation.setText(getString(R.string.fail_get_current_location)); break; } } else if (null != location && location.getLocType() == BDLocation.TypeNetWorkException) { switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockLocation.setText(getString(R.string.fail_get_current_location)); break; case STATE_OPERATION_UNLOCK: //解封 unlockLocation.setText(getString(R.string.fail_get_current_location)); break; } } else if (null != location && location.getLocType() == BDLocation.TypeCriteriaException) { switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockLocation.setText(getString(R.string.fail_get_current_location)); break; case STATE_OPERATION_UNLOCK: //解封 unlockLocation.setText(getString(R.string.fail_get_current_location)); break; } } isLocationServiceStarting = false; }
Example 13
Source File: DeviceOperationActivity.java From ESeal with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // TODO Auto-generated method stub if (null != location && location.getLocType() != BDLocation.TypeServerError) { String time = location.getTime(); double lat = location.getLatitude(); double lng = location.getLongitude(); String address = location.getAddrStr() + ", " + lat + "," + lng; // String address = lat + "," + lng; switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockTime.setText(time); lockLocation.setText(address); break; case STATE_OPERATION_UNLOCK: //解封 unlockTime.setText(time); unlockLocation.setText(address); break; case STATE_OPERATION_SETTING: //配置 coordinateSetting = lat + "," + lng; break; } } else if (null != location && location.getLocType() == BDLocation.TypeServerError) { switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockLocation.setText(getString(R.string.fail_get_current_location)); break; case STATE_OPERATION_UNLOCK: //解封 unlockLocation.setText(getString(R.string.fail_get_current_location)); break; } } else if (null != location && location.getLocType() == BDLocation.TypeNetWorkException) { switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockLocation.setText(getString(R.string.fail_get_current_location)); break; case STATE_OPERATION_UNLOCK: //解封 unlockLocation.setText(getString(R.string.fail_get_current_location)); break; } } else if (null != location && location.getLocType() == BDLocation.TypeCriteriaException) { switch (operationSealSwitch) { case STATE_OPERATION_LOCK: //上封 lockLocation.setText(getString(R.string.fail_get_current_location)); break; case STATE_OPERATION_UNLOCK: //解封 unlockLocation.setText(getString(R.string.fail_get_current_location)); break; } } isLocationServiceStarting = false; }
Example 14
Source File: DeviceMessageApplication.java From MapForTour with MIT License | 4 votes |
/** * 参数:location * 输出:location中的详细的位置信息 */ public String receiveLocationShowMessage(BDLocation location) { setLocation(location); longitude = location.getLongitude(); //经度 latitude = location.getLatitude(); //纬度 radius = location.getRadius(); //精度 address = location.getAddrStr(); this.latLng = new LatLng(latitude, longitude); //StringBuilder sb = new StringBuilder(256); // sb.append("经度:"); // sb.append(longitude); // sb.append(";纬度:"); // sb.append(latitude); // sb.append(";精度:"); // sb.append(radius); // sb.append("米"); // sb.append("\n错误代码:"); // sb.append(location.getLocType()); if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果 isLocateSuccess = true; isGPSLocation = true; latLngList.add(latLng); locateMode = "GPS定位"; // sb.append(";GPS定位成功"); // sb.append("\n速度:"); // sb.append(location.getSpeed());// 单位:公里每小时 // sb.append("km/s"); // sb.append(";星数:"); // sb.append(location.getSatelliteNumber()); // sb.append("颗;海拔:"); // sb.append(location.getAltitude());// 单位:米 // sb.append(";角度:"); // sb.append(location.getDirection());// 单位度 // sb.append("\n地址:"); // sb.append(location.getAddrStr()); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果 isLocateSuccess = true; isGPSLocation = false; locateMode = "网络定位"; // sb.append(";网络定位成功"); // sb.append("\n运营商:"); // sb.append(location.getOperators()); // sb.append("\n地址:"); // sb.append(location.getAddrStr()); } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果 isLocateSuccess = true; isGPSLocation = false; // sb.append("\n离线定位成功,离线定位结果也是有效的"); } else if (location.getLocType() == BDLocation.TypeServerError) { isLocateSuccess = false; isGPSLocation = false; // sb.append("\n服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); } else if (location.getLocType() == BDLocation.TypeNetWorkException) { isLocateSuccess = false; isGPSLocation = false; // sb.append("\n网络不同导致定位失败,请检查网络是否通畅"); } else if (location.getLocType() == BDLocation.TypeCriteriaException) { isLocateSuccess = false; isGPSLocation = false; // sb.append("\n无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); } // sb.toString(); return "success"; }
Example 15
Source File: SocialPublishActivity.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // //Receive Location // StringBuffer sb = new StringBuffer(256); // sb.append("time : "); // sb.append(location.getTime()); // sb.append("\nerror code : "); // sb.append(location.getLocType()); // sb.append("\nlatitude : "); // sb.append(location.getLatitude()); // sb.append("\nlontitude : "); // sb.append(location.getLongitude()); // sb.append("\nradius : "); // sb.append(location.getRadius()); // if (location.getLocType() == BDLocation.TypeGpsLocation){ // sb.append("\nspeed : "); // sb.append(location.getSpeed()); // sb.append("\nsatellite : "); // sb.append(location.getSatelliteNumber()); // sb.append("\ndirection : "); // sb.append("\naddr : "); // sb.append(location.getAddrStr()); // sb.append(location.getDirection()); // } else if (location.getLocType() == // BDLocation.TypeNetWorkLocation){ // sb.append("\naddr : "); // sb.append(location.getAddrStr()); // // sb.append("\noperationers : "); // sb.append(location.getOperators()); // } String str_addr = location.getAddrStr(); if (!TextUtils.isEmpty(str_addr)) { mLocationClient.stop(); tv_location.setText(str_addr); tv_cancel.setVisibility(View.VISIBLE); mylocation = str_addr; tv_cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tv_location.setText("所在位置"); tv_cancel.setVisibility(View.GONE); mylocation = ""; } }); } // Log.i("BaiduLocationApiDem", sb.toString()); }