上篇:Android使用百度LBS SDK(实现了百度地图的基本使用,记录轨迹,优化轨迹平滑度,轨迹查看与截图分享。)
今天再总结下测距和测速的使用:
计算轨迹起始点直线距离和路线距离
代码:
// 直线距离
double linearDistance = DistanceUtil.getDistance(llStart, llEnd);
// 轨迹距离
double routeDistance = 0.0;
for (int i = 0; i < points.size() - 1; i++) {
routeDistance = routeDistance
+ DistanceUtil.getDistance(points.get(i),
points.get(i + 1));
}
效果图:
去掉MapView的缩放控件和百度Logo
代码:
mMapView = (MapView) findViewById(R.id.routeMap);
// 去掉缩放控件和百度Logo
int count = mMapView.getChildCount();
for (int i = 0; i < count; i++) {
View child = mMapView.getChildAt(i);
if (child instanceof ImageView || child instanceof ZoomControls) {
child.setVisibility(View.INVISIBLE);
}
}
先写这么多,后续慢慢补充。
时间: 2024-10-13 08:54:38