我如何在 google 地图 android 中绘制自己的路线

How can i draw my own route in google map android

This is the code i have done to implement.I need to implement an application, where i need to add my own route in google map. I have tried it with direction API but it draw like this.Image which draw route like this.

我只需要在路上画一条多边形线。所以请给我一个更好的方法来实现它。

试试这个代码:

public void addPolylineToMap(GoogleMap map, List<LatLng> route) {
    final PolylineOptions polyline = new PolylineOptions();

    for (LatLng point : route) {
        polyline.add(point);
    }

    polyline.width(5)
            .color(Color.RED);

    map.addPolyline(polyline);
}