code: public List<Marker> addPointsToMapAsMarkers(GoogleMap map,
                                                  List<LatLng> points, MarkerOptions customMarkerOptions,
                                                  boolean ignoreIdenticalEnds) {
  
          List<Marker> markers = new ArrayList<Marker>();
          for (int i = 0; i < points.size(); i++) {
              LatLng latLng = points.get(i);
  
              if (points.size() > 1 && i + 1 == points.size() && ignoreIdenticalEnds) {
                  LatLng firstLatLng = points.get(0);
                  if (latLng.latitude == firstLatLng.latitude
                          && latLng.longitude == firstLatLng.longitude) {
                      break;
                  }
              }
  
              MarkerOptions markerOptions = new MarkerOptions();
              if (customMarkerOptions != null) {
                  markerOptions.icon(customMarkerOptions.getIcon());
                  markerOptions.anchor(customMarkerOptions.getAnchorU(),
                          customMarkerOptions.getAnchorV());
                  markerOptions.draggable(customMarkerOptions.isDraggable());
                  markerOptions.visible(customMarkerOptions.isVisible());
                  markerOptions.zIndex(customMarkerOptions.getZIndex());
              }
              Marker marker = addLatLngToMap(map, latLng, markerOptions);
              markers.add(marker);
          }
          return markers;
      }
docs: Add the list of points as markers
  
  @param map                 google map
  @param points              points
  @param customMarkerOptions custom marker options
  @param ignoreIdenticalEnds ignore identical ends flag
  @return list of markers