1616package com .google .maps .model ;
1717
1818import com .google .maps .internal .PolylineEncoding ;
19+ import com .google .maps .internal .StringJoin ;
20+
1921import java .io .Serializable ;
22+ import java .util .ArrayList ;
2023import java .util .List ;
2124
2225/**
@@ -29,6 +32,10 @@ public class EncodedPolyline implements Serializable {
2932
3033 private static final long serialVersionUID = 1L ;
3134
35+ private int weight ;
36+ private String color ;
37+ private String fillcolor ;
38+ private boolean geodesic ;
3239 private final String points ;
3340
3441 public EncodedPolyline () {
@@ -48,7 +55,7 @@ public EncodedPolyline(List<LatLng> points) {
4855 }
4956
5057 public String getEncodedPath () {
51- return points ;
58+ return toUrlValue () ;
5259 }
5360
5461 public List <LatLng > decodePath () {
@@ -61,4 +68,44 @@ public List<LatLng> decodePath() {
6168 public String toString () {
6269 return String .format ("[EncodedPolyline: %s]" , points );
6370 }
71+
72+ public void weight (int weight ) {
73+ this .weight = weight ;
74+ }
75+
76+ public void setColor (String color ) {
77+ this .color = color ;
78+ }
79+
80+ public void fillcolor (String fillcolor ) {
81+ this .fillcolor = fillcolor ;
82+ }
83+
84+ public void geodesic (boolean geodesic ) {
85+ this .geodesic = geodesic ;
86+ }
87+
88+ public String toUrlValue () {
89+ List <String > urlParts = new ArrayList <>();
90+
91+ if (weight > 0 ) {
92+ urlParts .add ("weight:" + weight );
93+ }
94+
95+ if (color != null ) {
96+ urlParts .add ("color:" + color );
97+ }
98+
99+ if (fillcolor != null ) {
100+ urlParts .add ("fillcolor:" + fillcolor );
101+ }
102+
103+ if (geodesic ) {
104+ urlParts .add ("geodesic:" + geodesic );
105+ }
106+
107+ urlParts .add ("enc:" + points );
108+
109+ return StringJoin .join ('|' , urlParts .toArray (new String [urlParts .size ()]));
110+ }
64111}
0 commit comments