
I am trying to build an application with google direction API on Android. I want apply direction mode as driving but when there is no route available, I want to apply dot polylines like Google Map App.
Bellow is sample code for apply polylines pattern for route from atabouraya's answer but it is opposite of what I want to apply.
public static final int PATTERN_GAP_LENGTH_PX = 20;
public static final PatternItem DOT = new Dot();
public static final PatternItem DASH = new Dash(PATTERN_DASH_LENGTH_PX);
public static final PatternItem GAP = new Gap(PATTERN_GAP_LENGTH_PX);
public static final List<PatternItem> PATTERN_POLYGON_ALPHA = Arrays.asList(GAP, DASH);
private void drawDashedLeg(GoogleMap googleMap, Route route) {
PolylineOptions polyOptions = new PolylineOptions();
polyOptions.color(ContextCompat.getColor(getContext(), R.color.coolgrey));
polyOptions.addAll(route.getPoints());
polyOptions.pattern(PATTERN_POLYGON_ALPHA);
Polyline polyline = googleMap.addPolyline(polyOptions);
polylines.add(polyline);
}
And here is another reference for how to draw curved dashed line on Google Map as they focus only how to draw curved line from one location to another.
My purpose is how to draw route from one location to another as driving route and apply walking mode when there is no route available.
Anyone who have any idea on this please help to share it. Thank you.