Reputation: 982
In my application I integrated google map with travel path. Currently I am using polyline to draw a path between source and destination. My query is I want to change the line into hyphen (-). I searched but I didn't get a solution. please help me, thanks in advance.
Upvotes: 3
Views: 4636
Reputation: 91
Now in Polyline you can set the pattern to be Dash, Dot or Gap simply apply the following:
public static final int PATTERN_DASH_LENGTH_PX = 20;
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);
...
PolylineOptions polylineOptions = new PolylineOptions()
.geodesic(true)
.color(Color.CYAN)
.width(10)
.pattern(PATTERN_POLYGON_ALPHA);
polylineOptions.addAll(route.getPoints());
polylinePaths.add(mGoogleMap.addPolyline(polylineOptions));
...
Upvotes: 6