android百度地图获取速度慢,android下百度地图的api怎么得到速度

很有可能你定位得到location,不是GPS产生的,而是网络定位产生的。因为前者有可能要1分钟多才能定位,而后者一般在1秒钟内就能定位。而后者,是没有速度的。

如需判断你的location是否是从GPS得到的,用location.getLocType() == BDLocation.TypeGpsLocation来判断。

请参考百度定位的示例代码:

public class MyLocationListener implements BDLocationListener {

@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());

}

logMsg(sb.toString());

Log.i("BaiduLocationApiDem", sb.toString());

}

}

取消

评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值