本文整理匯總了Java中com.baidu.location.BDLocation.getAddrStr方法的典型用法代碼示例。如果您正苦於以下問題:Java BDLocation.getAddrStr方法的具體用法?Java BDLocation.getAddrStr怎麽用?Java BDLocation.getAddrStr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.baidu.location.BDLocation
的用法示例。
在下文中一共展示了BDLocation.getAddrStr方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@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);
}
}
示例2: getCity
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
private void getCity() {
mListener = new BDLocationListener(){
@Override
public void onReceiveLocation(BDLocation location) {
if (null != location && location.getLocType() != BDLocation.TypeServerError){
city=location.getCity();
location_city.setText(location.getCity());
addess=location.getAddrStr();
Lat=location.getLatitude();
Lng=location.getLongitude();
Log.e("Address", addess);
Log.e("CCCC",city);
getDate();
}
}
};
}
示例3: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@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);
}
}
示例4: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
if (location == null) {
return;
}
for (int i = 0; i < 100; i++) {
L.i("" + location.getLocType());
latitude = location.getLatitude();
longitude = location.getLongitude();
address = location.getAddrStr();
L.i(latitude + "," + longitude + "," + location.getLocType());
if (location.getLocType() == 161 || location.getLocType() == 61) {
SP.put(mContext, Constant.LATI, latitude + "");
SP.put(mContext, Constant.LONG, longitude + "");
SP.put(mContext, Constant.ADDRESS, address + "");
break;
}
send();
}
}
示例5: prinftBDLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
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====================");
}
示例6: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@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);
}
示例7: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
public void onReceiveLocation(BDLocation location) {
if (location.getLocType() == BDLocation.TypeGpsLocation) {// 通過GPS定位
sb = location.getAddrStr();// 獲得當前地址
} else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 通過網絡連接定位
sb = location.getAddrStr();// 獲得當前地址
}
}
示例8: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@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);
}
示例9: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
if (location == null || mMapView == null) return;
MyLocationData locData = new MyLocationData.Builder()
.accuracy(location.getRadius())
.direction(100).latitude(location.getLatitude())
.longitude(location.getLongitude()).build();
mBaiduMap.setMyLocationData(locData);
if(isFirstLoc){
isFirstLoc = false;
currentPosition = location.getAddrStr();
myLocation = location;
}
}
示例10: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
if (location == null) {
return;
}
Log.d("map On location change received:" + location);
Log.d("map addr:" + location.getAddrStr());
sendButton.setEnabled(true);
if (progressDialog != null) {
progressDialog.dismiss();
}
if (lastLocation != null) {
if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) {
Log.d("map same location, skip refresh");
// mMapView.refresh(); //need this refresh?
return;
}
}
lastLocation = location;
GeoPoint gcj02Point = new GeoPoint((int) (location.getLatitude() * 1e6), (int) (location.getLongitude() * 1e6));
EMLog.d(TAG, "GCJ-02 loc:" + gcj02Point);
GeoPoint point = CoordinateConvert.fromGcjToBaidu(gcj02Point);
EMLog.d(TAG, "converted BD-09 loc:" + point);
// GeoPoint p1 = gcjToBaidu(location.getLatitude(),
// location.getLongitude());
// System.err.println("johnson change to baidu:" + p1);
// GeoPoint p2 = baiduToGcj(location.getLatitude(),
// location.getLongitude());
// System.err.println("johnson change to gcj:" + p2);
OverlayItem addrItem = new OverlayItem(point, "title", location.getAddrStr());
mAddrOverlay.removeAll();
mAddrOverlay.addItem(addrItem);
mMapView.getController().setZoom(17);
mMapView.refresh();
mMapController.animateTo(point);
}
示例11: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@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;
}
示例12: receiveLocationShowMessage
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
/**
* 參數: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";
}
示例13: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
DebugLog.d(TAG, "------------>>> onReceiveLocation()");
//如果此時沒有網絡了,就停止掉
//雖然開始的時候判斷了網絡,但是網絡有可能變化
if (!Environment.getInstance().isNetworkAvailable()) {
stop();
update(null);
return;
}
if (null == location) {
return;
} else {
if (location.getLocType() == BDLocation.TypeCriteriaException
|| location.getLocType() == BDLocation.TypeNetWorkException
|| location.getLocType() == BDLocation.TypeServerError
|| location.getLocType() == BDLocation.TypeNone) {
return;
}
}
final XAddress address = new XAddress();
double latitude = location.getLatitude();
if (0 != latitude) {
address.setLatitude("" + latitude);
}
double longitude = location.getLongitude();
if (0 != longitude) {
address.setLongtitude("" + longitude);
}
String province = location.getProvince();
if (null != province && !"".equals(province.trim())) {
address.setProvince(province);
}
String city = location.getCity();
if (null != province && !"".equals(province.trim())) {
address.setCity(city);
}
String district = location.getDistrict();
if (null != province && !"".equals(province.trim())) {
address.setArea(district);
}
String street = location.getStreet();
if (null != province && !"".equals(province.trim())) {
address.setStreet(street);
}
String addressName = location.getAddrStr();
if (null != addressName && !"".equals(addressName.trim())) {
address.setAddressName(addressName);
}
if ((0 != latitude) && (0 != longitude) && (null != addressName && !"".equals(addressName.trim()))) {
update(address);
//stop();
} else {
return;
}
/* if ((0 != longitude) && (0 != longitude) && (null != addressName && !"".equals(addressName.trim()))) {
ThreadPoolManager.EXECUTOR.execute(new Runnable() {
@Override
public void run() {
splitAddressName(address);
}
});
} else {
return;
}*/
}
示例14: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@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);
}
示例15: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@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()) {
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);
}