当前位置: 代码迷 >> JavaScript >> 求一份高德map的驾车查询实例
  详细解决方案

求一份高德map的驾车查询实例

热度:136   发布时间:2012-08-01 17:53:40.0
求一份高德地图的驾车查询实例
求一份高德地图的驾车查询实例~~

------解决方案--------------------
public void getRoute() {
GeoPoint startPoint = new GeoPoint(39908717, 116397516);
GeoPoint point1 = new GeoPoint(39908717,116459516);
FromAndTo fromAndTo = new FromAndTo(startPoint, point1);

try {
//Route.DrivingLeastDistance 为最短的行驶路线
List<Route> route = Route.calculateRoute(RouteDemo.this, fromAndTo,Route.DrivingLeastDistance);
// 构造RouteOverlay 参数为MapActivity cnt, Route rt。这里只取了查到路径的第一条。
if (route.size() > 0) {
routeOverlay = new RouteOverlay(RouteDemo.this, route.get(0));
routeOverlay.registerRouteMessage(rmHandler);// 注册人消息处理函数
routeOverlay.addToMap(mMapView);// 加入地图
routeOverlay.enableDrag(false);

int length = routeOverlay.getRoute().getLength();//获取路线长度
Log.e("route--length = >","总长为:"+length);
Toast.makeText(this, "length = "+length, Toast.LENGTH_SHORT);

} catch (AMapException e) {
e.printStackTrace();
}
}


两个点间的距离中短路径实现自驾车; 可以获取路线长度;可试试
  相关解决方案