本文整理匯總了Java中com.baidu.location.BDLocation.getRadius方法的典型用法代碼示例。如果您正苦於以下問題:Java BDLocation.getRadius方法的具體用法?Java BDLocation.getRadius怎麽用?Java BDLocation.getRadius使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.baidu.location.BDLocation
的用法示例。
在下文中一共展示了BDLocation.getRadius方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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()));
}
}
示例2: isLocationValid
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
public static boolean isLocationValid(BDLocation location) {
if (location == null)
return false;
if (location.getLongitude() <= 73)
return false;
if (location.getLongitude() >= 136)
return false;
if (location.getLatitude() <= 3)
return false;
if (location.getLatitude() >= 54)
return false;
if (location.getRadius() == 0)
return false;
if (location.getRadius() == 2000)
return false;
if (location.getLocType() == BDLocation.TypeCacheLocation)
return true;
if (location.getLocType() == BDLocation.TypeGpsLocation)
return true;
if (location.getLocType() == BDLocation.TypeNetWorkLocation)
return true;
if (location.getLocType() == BDLocation.TypeOffLineLocation)
return true;
return false;
}
示例3: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
if (location == null)
return ;
Intent intent = new Intent();
intent.setAction("com.hit.changyou");
intent.putExtra("city",location.getCity() );
BaiduMapActivity.this.sendBroadcast(intent);
locData.latitude = location.getLatitude();
locData.longitude = location.getLongitude();
locData.accuracy = location.getRadius();
locData.direction = location.getDerect();
myLocationOverlay.setData(locData);
mMapView.refresh();
Log.i("yxy", locData.latitude+";"+locData.longitude);
//定位預留
if (app.cityString.equals("")) {
mMapController.animateTo(new GeoPoint((int)(locData.latitude* 1e6), (int)(locData.longitude * 1e6)));
}
}
示例4: 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====================");
}
示例5: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
public void onReceiveLocation(BDLocation location) {
if (sp != null) {
Editor editor = sp.edit();
editor.putFloat("Latitude", (float) location.getLatitude());
editor.putFloat("Longitude", (float) location.getLongitude());
if (!editor.commit()) {
Toast.makeText(MapActivity.this, "����λ��ʧ��", 0).show();
}
}
address = location.getDistrict();
LocationData data = new LocationData();
data.accuracy = location.getRadius();
data.latitude = location.getLatitude();
data.longitude = location.getLongitude();
myLoc = new GeoPoint((int) (location.getLatitude() * 1e6),
(int) (location.getLongitude() * 1e6));
myLocation.setData(data);
mMapView.refresh();
mMapView.getController().animateTo(myLoc);
if (MapActivity.this.location != null) {
AnimationDrawable animdraw = (AnimationDrawable) MapActivity.this.location
.getBackground();
animdraw.stop();
MapActivity.this.location
.setBackgroundResource(R.drawable.btn_location);
MapActivity.this.location.setClickable(true);
if (!hasLocation) {
g.showButton();
hasLocation = !hasLocation;
}
}
Toast.makeText(MapActivity.this,
"��������λ���ǣ�" + location.getCity() + location.getDistrict(), 0)
.show();
}
示例6: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
if (location == null)
return ;
locData.latitude = location.getLatitude();
locData.longitude = location.getLongitude();
//如果不顯示定位精度圈,將accuracy賦值為0即可
locData.accuracy = location.getRadius();
locData.direction = location.getDerect();
//更新圖層數據執行刷新後生效
mMapView.refresh();
}
示例7: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
if (LocationUtils.isLocationInvalid(location))
return;
long time = System.currentTimeMillis();
double lng = location.getLongitude();
double lat = location.getLatitude();
LatLng latLng = new LatLng(lat, lng);
float radius = location.getRadius();
if (mIsInFront) {
MyLocationData.Builder builder = new MyLocationData.Builder();
builder.longitude(lng);
builder.latitude(lat);
builder.accuracy(radius);
builder.direction(DirectionUtils.getDirection());
MyLocationData myLocationData = builder.build();
mMapView.getMap().setMyLocationData(myLocationData);
if (mFollowMyLocation) {
MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(latLng);
mMapView.getMap().animateMapStatus(update);
}
}
if (radius > 0 && radius < 22) {
if (mLocationIndex++ == 0) {
mStartDialog.dismiss();
mStartButton.setImageResource(R.drawable.ic_stop);
mIsRecodingRoute = true;
mRoute = new ArrayList<LatLng>();
mRoute.add(latLng);
mLastRouteSize = 1;
mStartTime = time;
mLastLocation = location;
if (mIsInFront) {
mMapView.getMap().clear();
mBigDistanceView.setText("0.0 km");
mSmallDistanceView.setText("0.0 km");
mTimeSpanView.setText("0:00:00");
mAverageSpeedView.setText("0.0 km/h");
Toast.makeText(this, R.string.get_gps_location, Toast.LENGTH_SHORT).show();
}
} else {
LatLng latLng1 = new LatLng(location.getLatitude(), location.getLongitude());
LatLng latLng2 = new LatLng(mLastLocation.getLatitude(), mLastLocation.getLongitude());
mTotalDistance += DistanceUtil.getDistance(latLng1, latLng2);
if (lng != mLastLocation.getLongitude() || lat != mLastLocation.getLatitude()) {
mRoute.add(latLng);
}
mLastLocation = location;
if (mIsInFront) {
if (mRoute.size() > mLastRouteSize) {
MapViewUtils.clearOverlays(mMapView);
MapViewUtils.addLineOverlay(mMapView, mRoute, 0);
mLastRouteSize = mRoute.size();
}
DecimalFormat formatter = new DecimalFormat("0.0");
mBigDistanceView.setText(formatter.format(mTotalDistance / 1000) + " km");
mSmallDistanceView.setText(formatter.format(mTotalDistance / 1000) + " km");
mTimeSpanView.setText(StringFormatter.formatTime(time - mStartTime));
double avrSpeed = mTotalDistance * 1000 / (time - mStartTime);
mAverageSpeedView.setText(formatter.format(avrSpeed * 3600 / 1000) + " km/h");
}
}
}
}
示例8: 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";
}
示例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(mXDirection)
.latitude(location.getLatitude())
.longitude(location.getLongitude()).build();
mCurrentAccracy = location.getRadius();
mBaiduMap.setMyLocationData(locData);
mCurrentLantitude = location.getLatitude();
mCurrentLongitude = location.getLongitude();
OneBusApplication.CURRENT_POSITION = location.getAddrStr();
LatLng ll = new LatLng(location.getLatitude(),
location.getLongitude());
OneBusApplication.CURRENT_LOCATION = ll;
if (location.getCity() != null) {
OneBusApplication.GPS_CITY = location.getCity();
}
// Log.i("Coortype ",
// ""+location.getNetworkLocationType()+" : "+location.getCoorType()+" City:"+location.getCity());
if (isFirstLoc) {
isFirstLoc = false;
MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
mBaiduMap.animateMapStatus(u);
if (location.getCity() != null) {
Log.i("MainActivity",
"SharedPreferences Save Location And City");
SharedPreferences preferences = getSharedPreferences(
"LastLocation", Context.MODE_PRIVATE);
Editor editor = preferences.edit();
if (preferences.getBoolean("isFirstLocate", true)) {
OneBusApplication.CURRENT_CITY = location.getCity(); // If
// is
// the
// first
// locate,
editor.putBoolean("isFirstLocate", false); // set the
// current
// city as
// GpsCity
}
editor.putString("currentCity", location.getCity());
editor.putString("LastAddress", location.getAddrStr());
editor.commit();
preferences = null;
editor = null;
}
initNearby();
}
}
示例10: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
public void onReceiveLocation(BDLocation location)
{
if (null != location)
{
StringBuffer stringBuffer = new StringBuffer(256);
String locationTime = location.getTime();// 定位時間
int statusCode = location.getLocType();// 定位方式[61:GPS 161:NETWORK]
double longitude = location.getLongitude();// 經度
double latitude = location.getLatitude();// 緯度
float radius = location.getRadius();// 精度半徑
String address = location.getAddrStr();// 網絡定位時才有數據,地址信息
String city = location.getCity();
float speed = location.getSpeed();// GPS定位時才有數據
int satellite = location.getSatelliteNumber();// GPS定位時才有數據
if (longitude == LOCATION_FAILURED_LONGITUDE_LATITUDE)
{
longitude = SUZHOU_LONGITUDE;
latitude = SUZHOU_LATITUDE;
}
mLocationData.longitude = longitude;
mLocationData.latitude = latitude;
mLocationData.satellitesNum = satellite;
mLocationData.speed = speed;
stringBuffer.append("\nlocationTime[定位時間] = " + locationTime);
stringBuffer.append("\nstatusCode[定位方式[61:GPS 161:NETWORK]] = " + statusCode);
stringBuffer.append("\nlongitude[經度] = " + longitude);
stringBuffer.append("\nlatitude[緯度] = " + latitude);
stringBuffer.append("\nradius[精度半徑] = " + radius);
if (location.getLocType() == LOCATION_BY_GPS_CODE)
{
stringBuffer.append("\nspeed = " + speed);
stringBuffer.append("\nsatellite = " + satellite);
}
else if (location.getLocType() == LOCATION_BY_NETWORK_CODE)
{
stringBuffer.append("\naddress[地址信息] = " + address);
}
System.out.println("定位結果 = " + stringBuffer.toString());
if (!TextUtils.isEmpty(address))
{
Message message = mHandler.obtainMessage();
message.obj = address;
mHandler.sendMessageDelayed(message, DELAY_IN_MILLIS_SHOW_LOCATION_RESULT);
mPreferences.edit().putString(PREF_LOACTION_ADDRESS, address).commit();
}
if (!TextUtils.isEmpty(city))
{
mPreferences.edit().putString(PREF_LOACTION_CITY, city).commit();
}
}
}
示例11: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
// TODO Auto-generated method stub
if (location == null)
return;
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());
} else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {
sb.append("\naddr : ");
sb.append(location.getAddrStr());
}
Log.d("lbs message:", sb.toString());
mywd = location.getLatitude();
myjd = location.getLongitude();
locData.latitude = location.getLatitude();
locData.longitude = location.getLongitude();
// �������ʾ��λ����Ȧ����accuracy��ֵΪ0����
locData.accuracy = location.getRadius();
// �˴��������� locData�ķ�����Ϣ, �����λ SDK δ���ط�����Ϣ���û������Լ�ʵ�����̹�����ӷ�����Ϣ��
locData.direction = location.getDerect();
// locData.direction = 2.0f;
// ���¶�λ����
myLocationOverlay.setData(locData);
// ����ͼ������ִ��ˢ�º���Ч
mMapView.refresh();
// ���ֶ�����������״ζ�λʱ���ƶ�����λ��
if (isRequest || isFirstLoc) {
// �ƶ���ͼ����λ��
Log.d("LocationOverlay", "receive location, animate to it");
mMapController.animateTo(new GeoPoint(
(int) (locData.latitude * 1e6),
(int) (locData.longitude * 1e6)));
isRequest = false;
myLocationOverlay.setLocationMode(LocationMode.FOLLOWING);
}
// �״ζ�λ���
isFirstLoc = false;
}
示例12: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
// TODO Auto-generated method stub
if (location == null)
return;
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());
} else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {
sb.append("\naddr : ");
sb.append(location.getAddrStr());
}
Log.d("lbs message:", sb.toString());
locData.latitude = location.getLatitude();
locData.longitude = location.getLongitude();
addr = location.getAddrStr();
// �������ʾ��λ����Ȧ����accuracy��ֵΪ0����
locData.accuracy = location.getRadius();
// �˴��������� locData�ķ�����Ϣ, �����λ SDK δ���ط�����Ϣ���û������Լ�ʵ�����̹�����ӷ�����Ϣ��
locData.direction = location.getDerect();
// locData.direction = 2.0f;
// ���¶�λ����
myLocationOverlay.setData(locData);
// ����ͼ������ִ��ˢ�º���Ч
mMapView.refresh();
// ���ֶ�����������״ζ�λʱ���ƶ�����λ��
if (isRequest || isFirstLoc) {
// �ƶ���ͼ����λ��
Log.d("LocationOverlay", "receive location, animate to it");
mMapController.animateTo(new GeoPoint(
(int) (locData.latitude * 1e6),
(int) (locData.longitude * 1e6)));
isRequest = false;
myLocationOverlay.setLocationMode(LocationMode.FOLLOWING);
}
// �״ζ�λ���
isFirstLoc = false;
}
示例13: onReceiveLocation
import com.baidu.location.BDLocation; //導入方法依賴的package包/類
@Override
public void onReceiveLocation(BDLocation location) {
if (location == null)
return;
// locData.latitude = location.getLatitude();
// locData.longitude = location.getLongitude();
// // 如果不顯示定位精度圈,將accuracy賦值為0即可
// locData.accuracy = location.getRadius();
// // 此處可以設置 locData的方向信息, 如果定位 SDK
// // 未返回方向信息,用戶可以自己實現羅盤功能添加方向信息。
// locData.direction = location.getDerect();
// // 更新定位數據
// myLocationOverlay.setData(locData);
// // 更新圖層數據執行刷新後生效
// mMapView.refresh();
// // 是手動觸發請求或首次定位時,移動到定位點
// // if (isFirstLoc){
// // 移動地圖到定位點
// Log.d("LocationOverlay", "receive location, animate to it");
// locationPoint = new GeoPoint((int) (locData.latitude * 1e6),
// (int) (locData.longitude * 1e6));
// mMapView.getController().animateTo(locationPoint);
// mSearch.reverseGeocode(locationPoint);
locData.latitude = location.getLatitude();
locData.longitude = location.getLongitude();
//如果不顯示定位精度圈,將accuracy賦值為0即可
locData.accuracy = location.getRadius();
// 此處可以設置 locData的方向信息, 如果定位 SDK 未返回方向信息,用戶可以自己實現羅盤功能添加方向信息。
locData.direction = location.getDerect();
double tmpLongtitude = location.getLongitude();
double tmpLatitude = location.getLatitude();
longtitude = tmpLongtitude;
latitude = tmpLatitude;
//更新定位數據
myLocationOverlay.setData(locData);
//更新圖層數據執行刷新後生效
mMapView.refresh();
//是手動觸發請求或首次定位時,移動到定位點
locationPoint = new GeoPoint((int)(locData.latitude* 1e6), (int)(locData.longitude * 1e6));
if (isRequest || isFirstLoc){
//移動地圖到定位點
Log.d("LocationOverlay", "receive location, animate to it");
mMapController.animateTo(locationPoint);
isRequest = false;
myLocationOverlay.setLocationMode(LocationMode.FOLLOWING);
// myLocationOverlay.setData(locData);
mSearch.reverseGeocode(locationPoint);
}
mSearch.reverseGeocode(locationPoint);
//首次定位完成
isFirstLoc = false;
// }
// 首次定位完成
// isFirstLoc = false;
}