本文整理匯總了Java中com.baidu.location.BDLocation類的典型用法代碼示例。如果您正苦於以下問題:Java BDLocation類的具體用法?Java BDLocation怎麽用?Java BDLocation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BDLocation類屬於com.baidu.location包,在下文中一共展示了BDLocation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onReceiveLocation
import com.baidu.location.BDLocation; //導入依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// StringBuilder currentPosition=new StringBuilder();
// currentPosition.append("緯度:").append(location.getLatitude()).append("\n");
// currentPosition.append("經線:").append(location.getLongitude()).append("\n");
// currentPosition.append("國家:").append(location.getCountry()).append("\n");
// currentPosition.append("省:").append(location.getProvince()).append("\n");
// currentPosition.append("市:").append(location.getCity()).append("\n");
// currentPosition.append("區:").append(location.getDistrict()).append("\n");
// currentPosition.append("街道:").append(location.getStreet()).append("\n");
// currentPosition.append("定位方式: ");
// if (location.getLocType()==BDLocation.TypeGpsLocation){
// currentPosition.append("GPS");
// }else if (location.getLocType()==BDLocation.TypeNetWorkLocation){
// currentPosition.append("網絡");
// }
// positionText.setText(currentPosition);
// }
// });
if (location.getLocType()==BDLocation.TypeGpsLocation||location.getLocType()==BDLocation.TypeNetWorkLocation){
navigateTo(location);
}
}
示例2: onReceiveLocation
import com.baidu.location.BDLocation; //導入依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
if (null != location && location.getLocType() != BDLocation.TypeServerError) {
cityName = location.getCity();
provinceName = location.getProvince();
if (cityName != null) {
mCityName.setText(cityName.substring(0, cityName.length() - 1));
} else {
mCityName.setText("上海");
}
getCityWeather();
} else {
getCityWeather();
}
}
示例3: moveToMe
import com.baidu.location.BDLocation; //導入依賴的package包/類
private void moveToMe(BDLocation location)
{
MapStatusUpdate mapUpdate=MapStatusUpdateFactory.zoomTo(18);
baiduMap.setMapStatus(mapUpdate);
//開始移動
MapStatusUpdate mapLatlng=MapStatusUpdateFactory.newLatLng(new LatLng(location.getLatitude(),location.getLongitude()));
baiduMap.setMapStatus(mapLatlng);
//顯示我的位置
MyLocationData.Builder locationBuilder=new MyLocationData.Builder();
locationBuilder.latitude(location.getLatitude());
locationBuilder.longitude(location.getLongitude());
MyLocationData locationData=locationBuilder.build();
baiduMap.setMyLocationData(locationData);
//顯示用戶所在地附近
Toast.makeText(this,"您當前在"+location.getAddrStr()+"附近",Toast.LENGTH_SHORT).show();
}
示例4: call
import com.baidu.location.BDLocation; //導入依賴的package包/類
@Override
public void call(final Subscriber<? super BDLocation> subscriber) {
BDLocation lateKnownLocation = LocationClient.get(context).getLastKnownLocation();
if (lateKnownLocation != null) {
subscriber.onNext(lateKnownLocation);
subscriber.onCompleted();
} else {
BDLocationListener bdLocationListener = new BDLocationListener() {
@Override
public void onReceiveLocation(BDLocation bdLocation) {
subscriber.onNext(bdLocation);
subscriber.onCompleted();
}
};
LocationClient.get(context).locate(bdLocationListener);
}
}
示例5: navigateTo
import com.baidu.location.BDLocation; //導入依賴的package包/類
public void navigateTo(BDLocation location){
if(isFirstLocate){
LatLng latLng=new LatLng(location.getLatitude(),location.getLongitude());
showToast("定位到當前位置已執行");
MapStatusUpdate update=MapStatusUpdateFactory.zoomTo(8f);
baiduMap.animateMapStatus(update);
update= MapStatusUpdateFactory.newLatLng(latLng);
baiduMap.animateMapStatus(update);
isFirstLocate=false;
}
MyLocationData.Builder locationBuilder=new MyLocationData.Builder();
locationBuilder.latitude(location.getLatitude());
locationBuilder.longitude(location.getLongitude());
baiduMap.setMyLocationData(locationBuilder.build());
}
示例6: 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 = String.valueOf(location.getLatitude());
// 經度
mLongitude = String.valueOf(location.getLongitude());
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);
}
}
示例7: 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);
}
}
示例8: onReceiveLocation
import com.baidu.location.BDLocation; //導入依賴的package包/類
public void onReceiveLocation(BDLocation location) {
if (location != null && location.getLatitude() != Double.MIN_VALUE && location
.getLongitude() != Double.MIN_VALUE) {
Helper.showLog(SearchFriendsFragment.TAG, "baidu location requestLocation success" +
". ");
Helper.showLog(SearchFriendsFragment.TAG, "location update: <city>" + location
.getCity() + "</city><cityCode>" + location.getCityCode() +
"</cityCode><lat>" + location.getLatitude() + "</lat></lng>" + location
.getLongitude() + "</lng><time>" + DateHelper.getCurrentDateTime() +
"</time>");
SearchFriendsFragment.this.SerchNearByFriends(location);
} else if (SearchFriendsFragment.this.getActivity() != null) {
Helper.showLog(SearchFriendsFragment.TAG, "baidu location failed");
Helper.showToast(SearchFriendsFragment.this.getActivity(), (CharSequence)
"定位失敗,請檢查網絡");
}
}
示例9: onReceiveLocation
import com.baidu.location.BDLocation; //導入依賴的package包/類
@Override
public void onReceiveLocation(BDLocation arg0) {
isNeedRefresh=false;
if(arg0.getCity()==null){
//定位失敗
tvLocate.setText("未定位到城市,請選擇");
tvCurrentLocateCity.setVisibility(View.VISIBLE);
tvCurrentLocateCity.setText("重新選擇");
pbLocate.setVisibility(View.GONE);
return;
}else{
//定位成功
currentCity=arg0.getCity().substring(0,arg0.getCity().length()-1);
tvLocate.setText("當前定位城市");
tvCurrentLocateCity.setVisibility(View.VISIBLE);
tvCurrentLocateCity.setText(currentCity);
myLocationClient.stop();
pbLocate.setVisibility(View.GONE);
}
}
示例10: onReceiveLocation
import com.baidu.location.BDLocation; //導入依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
// map view 銷毀後不在處理新接收的位置
if (location == null) {
return;
}
sLocation = location;
if (mLocationListener != null) {
mLocationListener.onReceiveLocation(sLocation);
}
if (sNeedAutoClose) {
if (mLocClient.isStarted()) {
mLocClient.stop();
}
}
}
示例11: onReceiveLocation
import com.baidu.location.BDLocation; //導入依賴的package包/類
@Override
public void onReceiveLocation(BDLocation bdLocation) {
mLastLocationData=bdLocation;
MyLocationData myLocationData=new MyLocationData.Builder()
.accuracy(bdLocation.getRadius())
.latitude(bdLocation.getLatitude())
.longitude(bdLocation.getLongitude())
.build();
mBaiduMap.setMyLocationData(myLocationData);
MapStatusUpdate msu1 = MapStatusUpdateFactory.zoomTo(15.0f);
mBaiduMap.setMapStatus(msu1);
if(isFirstIn){
LatLng ll=new LatLng(bdLocation.getLatitude(),bdLocation.getLongitude());
MapStatusUpdate msu=MapStatusUpdateFactory.newLatLng(ll);
mBaiduMap.setMapStatus(msu);
isFirstIn=false;
}
}
示例12: onReceiveLocation
import com.baidu.location.BDLocation; //導入依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location){
latitude = location.getLatitude();
longitude = location.getLongitude();
Log.d(TAG, "onReceiveLocation: "+latitude+" "+longitude);
city = location.getCity();
if(city != null){
Log.d(TAG, city);
//更新定位狀態
mCityAdapter.updateLocateState(LocateState.SUCCESS,city.substring(0,city.length()-1));
locateSuccess = true;
}else {
mCityAdapter.updateLocateState(LocateState.FAILED,null);
locateSuccess = false;
}
}
示例13: onReceiveLocation
import com.baidu.location.BDLocation; //導入依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location){
lat = location.getLatitude();
lng = location.getLongitude();
city = location.getCity();
if(city != null){
Log.d(TAG, city);
if(!city.isEmpty()){
//定位成功,更新定位狀態
tvPosition.setText(city.substring(0,city.length()-1));
showAndHideActivityList(SHOW);
if(isFirstLoading){
getActivityList(lat,lng);
isFirstLoading = false;
}else {
getActivityListByType(mSelectedActivityType,mSelectedRankingType,lat,lng);
}
}else {
tvPosition.setText(getResources().getString(R.string.locate));
//定位失敗
showAndHideActivityList(HIDE);
}
}
}
示例14: onReceiveLocation
import com.baidu.location.BDLocation; //導入依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
// map view 銷毀後不在處理新接收的位置
if (location == null || mMapView == null) {
return;
}
mCurrentLat = location.getLatitude();
mCurrentLon = location.getLongitude();
mCurrentAccracy = location.getRadius();
locData = new MyLocationData.Builder()
.accuracy(location.getRadius())
// 此處設置開發者獲取到的方向信息,順時針0-360
.direction(mCurrentDirection).latitude(location.getLatitude())
.longitude(location.getLongitude()).build();
mBaiduMap.setMyLocationData(locData);
if (isFirstLoc) {
isFirstLoc = false;
LatLng ll = new LatLng(location.getLatitude(),
location.getLongitude());
MapStatus.Builder builder = new MapStatus.Builder();
builder.target(ll).zoom(18.0f);
mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
}
}
示例15: onReceiveLocation
import com.baidu.location.BDLocation; //導入依賴的package包/類
@Override
public final void onReceiveLocation(BDLocation bdLocation) {
if (null != bdLocation && bdLocation.getLocType() != BDLocation.TypeServerError) {
LocationEntity location = new LocationEntity(bdLocation);
onReceiveLocation(location);
String errorMsg = null;
if (bdLocation.getLocType() == BDLocation.TypeServerError) {
errorMsg = "服務端網絡定位失敗,可以反饋IMEI號和大體定位時間到[email protected],會有人追查原因";
} else if (bdLocation.getLocType() == BDLocation.TypeNetWorkException) {
errorMsg = "網絡不同導致定位失敗,請檢查網絡是否通暢";
} else if (bdLocation.getLocType() == BDLocation.TypeCriteriaException) {
errorMsg = "無法獲取有效定位依據導致定位失敗,一般是由於手機的原因,處於飛行模式下一般會造成這種結果,可以試著重啟手機";
}
if (!TextUtils.isEmpty(errorMsg)) {
onError(new Throwable(errorMsg));
}
} else {
onError(new Throwable("uncaught exception"));
}
}