@@ -32,13 +32,16 @@ -(void)setCoordinates:(NSArray<AIRMapCoordinate *> *)coordinates
32
32
[path addCoordinate: coordinates[i].coordinate];
33
33
}
34
34
35
- _polyline.path = path;
35
+ _polyline.path = path;
36
+
37
+ [self configureStyleSpansIfNeeded ];
36
38
}
37
39
38
40
-(void )setStrokeColor : (UIColor *)strokeColor
39
41
{
40
42
_strokeColor = strokeColor;
41
43
_polyline.strokeColor = strokeColor;
44
+ [self configureStyleSpansIfNeeded ];
42
45
}
43
46
44
47
-(void )setStrokeWidth : (double )strokeWidth
@@ -53,6 +56,11 @@ -(void)setFillColor:(UIColor *)fillColor
53
56
_polyline.spans = @[[GMSStyleSpan spanWithColor: fillColor]];
54
57
}
55
58
59
+ - (void )setLineDashPattern : (NSArray <NSNumber *> *)lineDashPattern {
60
+ _lineDashPattern = lineDashPattern;
61
+ [self configureStyleSpansIfNeeded ];
62
+ }
63
+
56
64
-(void )setGeodesic : (BOOL )geodesic
57
65
{
58
66
_geodesic = geodesic;
@@ -81,4 +89,23 @@ - (void)setOnPress:(RCTBubblingEventBlock)onPress {
81
89
_polyline.onPress = onPress;
82
90
}
83
91
92
+ - (void )configureStyleSpansIfNeeded {
93
+ if (!_strokeColor || !_lineDashPattern || !_polyline.path ) {
94
+ return ;
95
+ }
96
+
97
+ BOOL isLine = YES ;
98
+ NSMutableArray *styles = [[NSMutableArray alloc ] init ];
99
+ for (NSInteger i = 0 ; i < _lineDashPattern.count ; i++) {
100
+ if (isLine) {
101
+ [styles addObject: [GMSStrokeStyle solidColor: _strokeColor]];
102
+ } else {
103
+ [styles addObject: [GMSStrokeStyle solidColor: [UIColor clearColor ]]];
104
+ }
105
+ isLine = !isLine;
106
+ }
107
+
108
+ _polyline.spans = GMSStyleSpans (_polyline.path , styles, _lineDashPattern, kGMSLengthRhumb );
109
+ }
110
+
84
111
@end
0 commit comments