如何通过谷歌地图api绘制从当前位置到目的地的行车路线

时间:2017-06-23 19:59:56

标签: android google-maps google-maps-api-3

我需要从当前位置到目的地绘制一条行车线,包括所有航路点

@Override
public void onDirectionSuccess(Direction direction, String rawBody) {
    Log.d("Status", "Success");
    Log.d("Direction", "" + direction);
    mMap.addMarker(new MarkerOptions().position(origin));
    mMap.addMarker(new MarkerOptions().position(destination));
    if (waypoints != null){
        for (int i = 0; i < waypoints.size(); i++){
            mMap.addMarker(new MarkerOptions().position(waypoints.get(i)));
        }
    }

    ArrayList<LatLng> directionPositionList = direction.getRouteList().get(0).getLegList().get(0).getDirectionPoint();
    mMap.addPolyline(DirectionConverter.createPolyline(this, directionPositionList, 5, Color.BLUE));

    Log.d("Status", "Success 2");
    showRoute.setVisibility(View.GONE);
}

0 个答案:

没有答案