react-native-maps 1.16.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,10 @@ import android.content.Context;
4
4
 
5
5
  import com.facebook.react.bridge.ReadableArray;
6
6
  import com.facebook.react.bridge.ReadableMap;
7
+ import com.google.android.gms.maps.model.Dash;
8
+ import com.google.android.gms.maps.model.Gap;
7
9
  import com.google.android.gms.maps.model.LatLng;
10
+ import com.google.android.gms.maps.model.PatternItem;
8
11
  import com.google.android.gms.maps.model.Polygon;
9
12
  import com.google.android.gms.maps.model.PolygonOptions;
10
13
  import com.google.maps.android.collections.PolygonManager;
@@ -25,6 +28,8 @@ public class MapPolygon extends MapFeature {
25
28
  private boolean geodesic;
26
29
  private boolean tappable;
27
30
  private float zIndex;
31
+ private ReadableArray patternValues;
32
+ private List<PatternItem> pattern;
28
33
 
29
34
  public MapPolygon(Context context) {
30
35
  super(context);
@@ -117,6 +122,32 @@ public class MapPolygon extends MapFeature {
117
122
  }
118
123
  }
119
124
 
125
+ public void setLineDashPattern(ReadableArray patternValues) {
126
+ this.patternValues = patternValues;
127
+ this.applyPattern();
128
+ }
129
+
130
+ private void applyPattern() {
131
+ if(patternValues == null) {
132
+ return;
133
+ }
134
+ this.pattern = new ArrayList<>(patternValues.size());
135
+ for (int i = 0; i < patternValues.size(); i++) {
136
+ float patternValue = (float) patternValues.getDouble(i);
137
+ boolean isGap = i % 2 != 0;
138
+ if(isGap) {
139
+ this.pattern.add(new Gap(patternValue));
140
+ }else {
141
+ PatternItem patternItem;
142
+ patternItem = new Dash(patternValue);
143
+ this.pattern.add(patternItem);
144
+ }
145
+ }
146
+ if(polygon != null) {
147
+ polygon.setStrokePattern(this.pattern);
148
+ }
149
+ }
150
+
120
151
  public PolygonOptions getPolygonOptions() {
121
152
  if (polygonOptions == null) {
122
153
  polygonOptions = createPolygonOptions();
@@ -132,6 +163,7 @@ public class MapPolygon extends MapFeature {
132
163
  options.strokeWidth(strokeWidth);
133
164
  options.geodesic(geodesic);
134
165
  options.zIndex(zIndex);
166
+ options.strokePattern(this.pattern);
135
167
 
136
168
  if (this.holes != null) {
137
169
  for (int i = 0; i < holes.size(); i++) {
@@ -78,6 +78,11 @@ public class MapPolygonManager extends ViewGroupManager<MapPolygon> {
78
78
  view.setZIndex(zIndex);
79
79
  }
80
80
 
81
+ @ReactProp(name = "lineDashPattern")
82
+ public void setLineDashPattern(MapPolygon view, ReadableArray patternValues) {
83
+ view.setLineDashPattern(patternValues);
84
+ }
85
+
81
86
  @Override
82
87
  @Nullable
83
88
  public Map getExportedCustomDirectEventTypeConstants() {
package/lib/Geojson.d.ts CHANGED
@@ -55,7 +55,7 @@ export type GeojsonProps = {
55
55
  * @platform iOS: Supported
56
56
  * @platform Android: Supported
57
57
  */
58
- lineDashPattern?: PolylineProps['lineDashPattern'];
58
+ lineDashPattern?: PolygonProps['lineDashPattern'] | PolylineProps['lineDashPattern'];
59
59
  /**
60
60
  * The offset (in points) at which to start drawing the dash pattern.
61
61
  *
@@ -51,7 +51,7 @@ export type MapPolygonProps = ViewProps & {
51
51
  * followed by the first gap length, followed by the second line segment length, and so on.
52
52
  *
53
53
  * @platform iOS: Apple Maps only
54
- * @platform Android: Not supported
54
+ * @platform Android: Supported
55
55
  */
56
56
  lineDashPattern?: number[];
57
57
  /**
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "main": "lib/index.js",
6
6
  "author": "Leland Richardson <leland.m.richardson@gmail.com>",
7
7
  "homepage": "https://github.com/react-native-maps/react-native-maps#readme",
8
- "version": "1.16.0",
8
+ "version": "1.17.0",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",