react-native-maps 1.21.0-alpha.79 → 1.21.0-alpha.80

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.
Files changed (33) hide show
  1. package/android/generated/java/com/facebook/react/viewmanagers/RNMapsPolylineManagerDelegate.java +58 -0
  2. package/android/generated/java/com/facebook/react/viewmanagers/RNMapsPolylineManagerInterface.java +27 -0
  3. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +1 -0
  4. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +1 -0
  5. package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +22 -0
  6. package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +22 -0
  7. package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.cpp +15 -0
  8. package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.h +83 -0
  9. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +1 -0
  10. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +11 -0
  11. package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.h +12 -0
  12. package/android/src/main/java/com/rnmaps/fabric/PolylineManager.java +121 -0
  13. package/android/src/main/java/com/rnmaps/fabric/event/OnPanDragEvent.java +28 -0
  14. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +5 -1
  15. package/android/src/main/java/com/rnmaps/maps/MapPolyline.java +207 -141
  16. package/android/src/main/java/com/rnmaps/maps/MapPolylineManager.java +1 -16
  17. package/android/src/main/java/com/rnmaps/maps/MapView.java +2 -3
  18. package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +1 -0
  19. package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +1 -0
  20. package/ios/generated/RNMapsSpecs/EventEmitters.cpp +22 -0
  21. package/ios/generated/RNMapsSpecs/EventEmitters.h +22 -0
  22. package/ios/generated/RNMapsSpecs/Props.cpp +15 -0
  23. package/ios/generated/RNMapsSpecs/Props.h +83 -0
  24. package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +4 -0
  25. package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +1 -0
  26. package/ios/generated/RNMapsSpecs/ShadowNodes.h +11 -0
  27. package/ios/generated/RNMapsSpecs/States.h +12 -0
  28. package/lib/MapCallout.js +0 -1
  29. package/lib/MapPolyline.d.ts +5 -5
  30. package/lib/decorateMapComponent.js +10 -3
  31. package/lib/specs/NativeComponentPolyline.d.ts +101 -0
  32. package/lib/specs/NativeComponentPolyline.js +7 -0
  33. package/package.json +1 -1
@@ -4,161 +4,227 @@ 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.facebook.react.common.MapBuilder;
8
+ import com.google.android.gms.maps.model.ButtCap;
7
9
  import com.google.android.gms.maps.model.Cap;
8
10
  import com.google.android.gms.maps.model.Dash;
9
11
  import com.google.android.gms.maps.model.Dot;
10
12
  import com.google.android.gms.maps.model.Gap;
13
+ import com.google.android.gms.maps.model.JointType;
11
14
  import com.google.android.gms.maps.model.LatLng;
12
15
  import com.google.android.gms.maps.model.PatternItem;
13
16
  import com.google.android.gms.maps.model.Polyline;
14
17
  import com.google.android.gms.maps.model.PolylineOptions;
15
18
  import com.google.android.gms.maps.model.RoundCap;
19
+ import com.google.android.gms.maps.model.SquareCap;
20
+ import com.google.android.gms.maps.model.StrokeStyle;
21
+ import com.google.android.gms.maps.model.StyleSpan;
16
22
  import com.google.maps.android.collections.PolylineManager;
23
+ import com.rnmaps.fabric.event.OnPressEvent;
17
24
 
18
25
  import java.util.ArrayList;
19
26
  import java.util.List;
27
+ import java.util.Map;
20
28
 
21
29
  public class MapPolyline extends MapFeature {
22
30
 
23
- private PolylineOptions polylineOptions;
24
- private Polyline polyline;
25
-
26
- private List<LatLng> coordinates;
27
- private int color;
28
- private float width;
29
- private boolean tappable;
30
- private boolean geodesic;
31
- private float zIndex;
32
- private Cap lineCap = new RoundCap();
33
- private ReadableArray patternValues;
34
- private List<PatternItem> pattern;
35
-
36
- public MapPolyline(Context context) {
37
- super(context);
38
- }
39
-
40
- public void setCoordinates(ReadableArray coordinates) {
41
- this.coordinates = new ArrayList<>(coordinates.size());
42
- for (int i = 0; i < coordinates.size(); i++) {
43
- ReadableMap coordinate = coordinates.getMap(i);
44
- this.coordinates.add(i,
45
- new LatLng(coordinate.getDouble("latitude"), coordinate.getDouble("longitude")));
46
- }
47
- if (polyline != null) {
48
- polyline.setPoints(this.coordinates);
49
- }
50
- }
51
-
52
- public void setColor(int color) {
53
- this.color = color;
54
- if (polyline != null) {
55
- polyline.setColor(color);
56
- }
57
- }
58
-
59
- public void setWidth(float width) {
60
- this.width = width;
61
- if (polyline != null) {
62
- polyline.setWidth(width);
63
- }
64
- }
65
-
66
- public void setZIndex(float zIndex) {
67
- this.zIndex = zIndex;
68
- if (polyline != null) {
69
- polyline.setZIndex(zIndex);
70
- }
71
- }
72
-
73
- public void setTappable(boolean tapabble) {
74
- this.tappable = tapabble;
75
- if (polyline != null) {
76
- polyline.setClickable(tappable);
77
- }
78
- }
79
-
80
- public void setGeodesic(boolean geodesic) {
81
- this.geodesic = geodesic;
82
- if (polyline != null) {
83
- polyline.setGeodesic(geodesic);
84
- }
85
- }
86
-
87
- public void setLineCap(Cap cap) {
88
- this.lineCap = cap;
89
- if (polyline != null) {
90
- polyline.setStartCap(cap);
91
- polyline.setEndCap(cap);
92
- }
93
- this.applyPattern();
94
- }
95
-
96
- public void setLineDashPattern(ReadableArray patternValues) {
97
- this.patternValues = patternValues;
98
- this.applyPattern();
99
- }
100
-
101
- private void applyPattern() {
102
- if(patternValues == null) {
103
- return;
104
- }
105
- this.pattern = new ArrayList<>(patternValues.size());
106
- for (int i = 0; i < patternValues.size(); i++) {
107
- float patternValue = (float) patternValues.getDouble(i);
108
- boolean isGap = i % 2 != 0;
109
- if(isGap) {
110
- this.pattern.add(new Gap(patternValue));
111
- }else {
112
- PatternItem patternItem;
113
- boolean isLineCapRound = this.lineCap instanceof RoundCap;
114
- if(isLineCapRound) {
115
- patternItem = new Dot();
116
- }else {
117
- patternItem = new Dash(patternValue);
118
- }
119
- this.pattern.add(patternItem);
120
- }
121
- }
122
- if(polyline != null) {
123
- polyline.setPattern(this.pattern);
124
- }
125
- }
126
-
127
- public PolylineOptions getPolylineOptions() {
128
- if (polylineOptions == null) {
129
- polylineOptions = createPolylineOptions();
130
- }
131
- return polylineOptions;
132
- }
133
-
134
- private PolylineOptions createPolylineOptions() {
135
- PolylineOptions options = new PolylineOptions();
136
- options.addAll(coordinates);
137
- options.color(color);
138
- options.width(width);
139
- options.geodesic(geodesic);
140
- options.zIndex(zIndex);
141
- options.startCap(lineCap);
142
- options.endCap(lineCap);
143
- options.pattern(this.pattern);
144
- return options;
145
- }
146
-
147
- @Override
148
- public Object getFeature() {
149
- return polyline;
150
- }
151
-
152
- @Override
153
- public void addToMap(Object collection) {
154
- PolylineManager.Collection polylineCollection = (PolylineManager.Collection) collection;
155
- polyline = polylineCollection.addPolyline(getPolylineOptions());
156
- polyline.setClickable(this.tappable);
157
- }
158
-
159
- @Override
160
- public void removeFromMap(Object collection) {
161
- PolylineManager.Collection polylineCollection = (PolylineManager.Collection) collection;
162
- polylineCollection.remove(polyline);
163
- }
31
+ private PolylineOptions polylineOptions;
32
+ private Polyline polyline;
33
+
34
+ private List<LatLng> coordinates;
35
+ private int color;
36
+ private float width;
37
+ private boolean tappable;
38
+ private boolean geodesic;
39
+ private float zIndex;
40
+ private Cap lineCap = new RoundCap();
41
+ private ReadableArray patternValues;
42
+ private List<PatternItem> pattern;
43
+
44
+ public MapPolyline(Context context) {
45
+ super(context);
46
+ }
47
+
48
+ public void setCoordinates(ReadableArray coordinates) {
49
+ this.coordinates = new ArrayList<>(coordinates.size());
50
+ for (int i = 0; i < coordinates.size(); i++) {
51
+ ReadableMap coordinate = coordinates.getMap(i);
52
+ this.coordinates.add(i,
53
+ new LatLng(coordinate.getDouble("latitude"), coordinate.getDouble("longitude")));
54
+ }
55
+ if (polyline != null) {
56
+ polyline.setPoints(this.coordinates);
57
+ }
58
+ }
59
+
60
+ public void setColor(int color) {
61
+ this.color = color;
62
+ if (polyline != null) {
63
+ polyline.setColor(color);
64
+ }
65
+ }
66
+
67
+ public void setStrokeColors(ReadableArray strokeColors) {
68
+ List<StyleSpan> spans = new ArrayList<>();
69
+ for (int i = 0; i < strokeColors.size(); i++) {
70
+ StrokeStyle stroke;
71
+
72
+ if (i == 0) {
73
+ stroke = StrokeStyle.colorBuilder(strokeColors.getInt(i)).build();
74
+ } else {
75
+ stroke = StrokeStyle.gradientBuilder(strokeColors.getInt(i - 1), strokeColors.getInt(i)).build();
76
+ }
77
+ spans.add(new StyleSpan(stroke));
78
+ }
79
+
80
+ polyline.setSpans(spans);
81
+ }
82
+
83
+ public void setWidth(float width) {
84
+ this.width = width;
85
+ if (polyline != null) {
86
+ polyline.setWidth(width);
87
+ }
88
+ }
89
+
90
+ public void setZIndex(float zIndex) {
91
+ this.zIndex = zIndex;
92
+ if (polyline != null) {
93
+ polyline.setZIndex(zIndex);
94
+ }
95
+ }
96
+
97
+ public void setTappable(boolean tapabble) {
98
+ this.tappable = tapabble;
99
+ if (polyline != null) {
100
+ polyline.setClickable(tappable);
101
+ }
102
+ }
103
+
104
+ public void setGeodesic(boolean geodesic) {
105
+ this.geodesic = geodesic;
106
+ if (polyline != null) {
107
+ polyline.setGeodesic(geodesic);
108
+ }
109
+ }
110
+
111
+ public void setLineCap(Cap cap) {
112
+ this.lineCap = cap;
113
+ if (polyline != null) {
114
+ polyline.setStartCap(cap);
115
+ polyline.setEndCap(cap);
116
+ }
117
+ this.applyPattern();
118
+ }
119
+
120
+ public void setLineDashPattern(ReadableArray patternValues) {
121
+ this.patternValues = patternValues;
122
+ this.applyPattern();
123
+ }
124
+
125
+ private void applyPattern() {
126
+ if (patternValues == null) {
127
+ return;
128
+ }
129
+ this.pattern = new ArrayList<>(patternValues.size());
130
+ for (int i = 0; i < patternValues.size(); i++) {
131
+ float patternValue = (float) patternValues.getDouble(i);
132
+ boolean isGap = i % 2 != 0;
133
+ if (isGap) {
134
+ this.pattern.add(new Gap(patternValue));
135
+ } else {
136
+ PatternItem patternItem;
137
+ boolean isLineCapRound = this.lineCap instanceof RoundCap;
138
+ if (isLineCapRound) {
139
+ patternItem = new Dot();
140
+ } else {
141
+ patternItem = new Dash(patternValue);
142
+ }
143
+ this.pattern.add(patternItem);
144
+ }
145
+ }
146
+ if (polyline != null) {
147
+ polyline.setPattern(this.pattern);
148
+ }
149
+ }
150
+
151
+ public PolylineOptions getPolylineOptions() {
152
+ if (polylineOptions == null) {
153
+ polylineOptions = createPolylineOptions();
154
+ }
155
+ return polylineOptions;
156
+ }
157
+
158
+ private PolylineOptions createPolylineOptions() {
159
+ PolylineOptions options = new PolylineOptions();
160
+ options.addAll(coordinates);
161
+ options.color(color);
162
+ options.width(width);
163
+ options.geodesic(geodesic);
164
+ options.zIndex(zIndex);
165
+ options.startCap(lineCap);
166
+ options.endCap(lineCap);
167
+ options.pattern(this.pattern);
168
+ return options;
169
+ }
170
+
171
+ @Override
172
+ public Object getFeature() {
173
+ return polyline;
174
+ }
175
+
176
+ @Override
177
+ public void addToMap(Object collection) {
178
+ PolylineManager.Collection polylineCollection = (PolylineManager.Collection) collection;
179
+ polyline = polylineCollection.addPolyline(getPolylineOptions());
180
+ polyline.setClickable(this.tappable);
181
+ }
182
+
183
+ @Override
184
+ public void removeFromMap(Object collection) {
185
+ PolylineManager.Collection polylineCollection = (PolylineManager.Collection) collection;
186
+ polylineCollection.remove(polyline);
187
+ }
188
+
189
+ public void setLineCap(String lineCap) {
190
+ Cap cap;
191
+ switch (lineCap) {
192
+ case "round":
193
+ cap = new RoundCap();
194
+ break;
195
+ case "square":
196
+ cap = new SquareCap();
197
+ break;
198
+ case "butt":
199
+ default:
200
+ cap = new ButtCap();
201
+ break;
202
+ }
203
+ setLineCap(cap);
204
+ }
205
+
206
+ public static Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
207
+ MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
208
+ builder.put(OnPressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnPressEvent.EVENT_NAME));
209
+ return builder.build();
210
+ }
211
+
212
+ public void setLineJoin(String lineJoin) {
213
+ int type;
214
+ switch (lineJoin) {
215
+ case "round":
216
+ type = JointType.ROUND;
217
+ break;
218
+ case "bevel":
219
+ type = JointType.BEVEL;
220
+ break;
221
+ case "miter":
222
+ default:
223
+ type = JointType.DEFAULT;
224
+ break;
225
+ }
226
+ if (polyline != null) {
227
+ polyline.setJointType(type);
228
+ }
229
+ }
164
230
  }
@@ -74,22 +74,7 @@ public class MapPolylineManager extends ViewGroupManager<MapPolyline> {
74
74
 
75
75
  @ReactProp(name = "lineCap")
76
76
  public void setlineCap(MapPolyline view, String lineCap) {
77
- Cap cap = null;
78
- switch (lineCap) {
79
- case "butt":
80
- cap = new ButtCap();
81
- break;
82
- case "round":
83
- cap = new RoundCap();
84
- break;
85
- case "square":
86
- cap = new SquareCap();
87
- break;
88
- default:
89
- cap = new RoundCap();
90
- break;
91
- }
92
- view.setLineCap(cap);
77
+ view.setLineCap(lineCap);
93
78
  }
94
79
 
95
80
  @ReactProp(name = "lineDashPattern")
@@ -654,6 +654,7 @@ public void onCreate(LifecycleOwner owner) {
654
654
  builder.put(OnLongPressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnLongPressEvent.EVENT_NAME));
655
655
  builder.put(OnRegionChangeStartEvent.EVENT_NAME, MapBuilder.of("registrationName", OnRegionChangeStartEvent.EVENT_NAME));
656
656
  builder.put(OnDoublePressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnDoublePressEvent.EVENT_NAME));
657
+ builder.put(OnPanDragEvent.EVENT_NAME, MapBuilder.of("registrationName", OnPanDragEvent.EVENT_NAME));
657
658
  return builder.build();
658
659
  }
659
660
 
@@ -1612,8 +1613,7 @@ public void onCreate(LifecycleOwner owner) {
1612
1613
  Point point = new Point((int) ev.getX(), (int) ev.getY());
1613
1614
  LatLng coords = this.map.getProjection().fromScreenLocation(point);
1614
1615
  WritableMap event = makeClickEventData(coords);
1615
- // todo: use Fabric events
1616
- // manager.pushEvent(context, this, "onPanDrag", event);
1616
+ dispatchEvent(event, OnPanDragEvent::new);
1617
1617
  }
1618
1618
 
1619
1619
  public void onDoublePress(MotionEvent ev) {
@@ -1621,7 +1621,6 @@ public void onCreate(LifecycleOwner owner) {
1621
1621
  Point point = new Point((int) ev.getX(), (int) ev.getY());
1622
1622
  LatLng coords = this.map.getProjection().fromScreenLocation(point);
1623
1623
  WritableMap event = makeClickEventData(coords);
1624
- // todo: use Fabric events
1625
1624
  dispatchEvent(event, OnDoublePressEvent::new);
1626
1625
 
1627
1626
  }
@@ -21,6 +21,7 @@ registry->add(concreteComponentDescriptorProvider<RNMapsGoogleMapViewComponentDe
21
21
  registry->add(concreteComponentDescriptorProvider<RNMapsGooglePolygonComponentDescriptor>());
22
22
  registry->add(concreteComponentDescriptorProvider<RNMapsMapViewComponentDescriptor>());
23
23
  registry->add(concreteComponentDescriptorProvider<RNMapsMarkerComponentDescriptor>());
24
+ registry->add(concreteComponentDescriptorProvider<RNMapsPolylineComponentDescriptor>());
24
25
  }
25
26
 
26
27
  } // namespace facebook::react
@@ -21,6 +21,7 @@ using RNMapsGoogleMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMap
21
21
  using RNMapsGooglePolygonComponentDescriptor = ConcreteComponentDescriptor<RNMapsGooglePolygonShadowNode>;
22
22
  using RNMapsMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMapsMapViewShadowNode>;
23
23
  using RNMapsMarkerComponentDescriptor = ConcreteComponentDescriptor<RNMapsMarkerShadowNode>;
24
+ using RNMapsPolylineComponentDescriptor = ConcreteComponentDescriptor<RNMapsPolylineShadowNode>;
24
25
 
25
26
  void RNMapsSpecs_registerComponentDescriptorsFromCodegen(
26
27
  std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
@@ -915,4 +915,26 @@ $payload.setProperty(runtime, "id", $event.id);
915
915
  });
916
916
  }
917
917
 
918
+
919
+ void RNMapsPolylineEventEmitter::onPress(OnPress $event) const {
920
+ dispatchEvent("press", [$event=std::move($event)](jsi::Runtime &runtime) {
921
+ auto $payload = jsi::Object(runtime);
922
+ $payload.setProperty(runtime, "action", $event.action);
923
+ $payload.setProperty(runtime, "id", $event.id);
924
+ {
925
+ auto coordinate = jsi::Object(runtime);
926
+ coordinate.setProperty(runtime, "latitude", $event.coordinate.latitude);
927
+ coordinate.setProperty(runtime, "longitude", $event.coordinate.longitude);
928
+ $payload.setProperty(runtime, "coordinate", coordinate);
929
+ }
930
+ {
931
+ auto position = jsi::Object(runtime);
932
+ position.setProperty(runtime, "x", $event.position.x);
933
+ position.setProperty(runtime, "y", $event.position.y);
934
+ $payload.setProperty(runtime, "position", position);
935
+ }
936
+ return $payload;
937
+ });
938
+ }
939
+
918
940
  } // namespace facebook::react
@@ -784,4 +784,26 @@ class RNMapsMarkerEventEmitter : public ViewEventEmitter {
784
784
 
785
785
  void onSelect(OnSelect value) const;
786
786
  };
787
+ class RNMapsPolylineEventEmitter : public ViewEventEmitter {
788
+ public:
789
+ using ViewEventEmitter::ViewEventEmitter;
790
+
791
+ struct OnPressCoordinate {
792
+ double latitude;
793
+ double longitude;
794
+ };
795
+
796
+ struct OnPressPosition {
797
+ double x;
798
+ double y;
799
+ };
800
+
801
+ struct OnPress {
802
+ std::string action;
803
+ std::string id;
804
+ OnPressCoordinate coordinate;
805
+ OnPressPosition position;
806
+ };
807
+ void onPress(OnPress value) const;
808
+ };
787
809
  } // namespace facebook::react
@@ -151,5 +151,20 @@ RNMapsMarkerProps::RNMapsMarkerProps(
151
151
  subtitleVisibility(convertRawProp(context, rawProps, "subtitleVisibility", sourceProps.subtitleVisibility, {RNMapsMarkerSubtitleVisibility::Adaptive})),
152
152
  useLegacyPinView(convertRawProp(context, rawProps, "useLegacyPinView", sourceProps.useLegacyPinView, {false}))
153
153
  {}
154
+ RNMapsPolylineProps::RNMapsPolylineProps(
155
+ const PropsParserContext &context,
156
+ const RNMapsPolylineProps &sourceProps,
157
+ const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
158
+
159
+ coordinates(convertRawProp(context, rawProps, "coordinates", sourceProps.coordinates, {})),
160
+ geodesic(convertRawProp(context, rawProps, "geodesic", sourceProps.geodesic, {false})),
161
+ lineCap(convertRawProp(context, rawProps, "lineCap", sourceProps.lineCap, {RNMapsPolylineLineCap::Butt})),
162
+ lineDashPattern(convertRawProp(context, rawProps, "lineDashPattern", sourceProps.lineDashPattern, {})),
163
+ lineJoin(convertRawProp(context, rawProps, "lineJoin", sourceProps.lineJoin, {RNMapsPolylineLineJoin::Miter})),
164
+ strokeColor(convertRawProp(context, rawProps, "strokeColor", sourceProps.strokeColor, {})),
165
+ strokeColors(convertRawProp(context, rawProps, "strokeColors", sourceProps.strokeColors, {})),
166
+ strokeWidth(convertRawProp(context, rawProps, "strokeWidth", sourceProps.strokeWidth, {0.0})),
167
+ tappable(convertRawProp(context, rawProps, "tappable", sourceProps.tappable, {false}))
168
+ {}
154
169
 
155
170
  } // namespace facebook::react
@@ -1056,4 +1056,87 @@ class RNMapsMarkerProps final : public ViewProps {
1056
1056
  bool useLegacyPinView{false};
1057
1057
  };
1058
1058
 
1059
+ enum class RNMapsPolylineLineCap { Butt, Round, Square };
1060
+
1061
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsPolylineLineCap &result) {
1062
+ auto string = (std::string)value;
1063
+ if (string == "butt") { result = RNMapsPolylineLineCap::Butt; return; }
1064
+ if (string == "round") { result = RNMapsPolylineLineCap::Round; return; }
1065
+ if (string == "square") { result = RNMapsPolylineLineCap::Square; return; }
1066
+ abort();
1067
+ }
1068
+
1069
+ static inline std::string toString(const RNMapsPolylineLineCap &value) {
1070
+ switch (value) {
1071
+ case RNMapsPolylineLineCap::Butt: return "butt";
1072
+ case RNMapsPolylineLineCap::Round: return "round";
1073
+ case RNMapsPolylineLineCap::Square: return "square";
1074
+ }
1075
+ }
1076
+ enum class RNMapsPolylineLineJoin { Miter, Round, Bevel };
1077
+
1078
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsPolylineLineJoin &result) {
1079
+ auto string = (std::string)value;
1080
+ if (string == "miter") { result = RNMapsPolylineLineJoin::Miter; return; }
1081
+ if (string == "round") { result = RNMapsPolylineLineJoin::Round; return; }
1082
+ if (string == "bevel") { result = RNMapsPolylineLineJoin::Bevel; return; }
1083
+ abort();
1084
+ }
1085
+
1086
+ static inline std::string toString(const RNMapsPolylineLineJoin &value) {
1087
+ switch (value) {
1088
+ case RNMapsPolylineLineJoin::Miter: return "miter";
1089
+ case RNMapsPolylineLineJoin::Round: return "round";
1090
+ case RNMapsPolylineLineJoin::Bevel: return "bevel";
1091
+ }
1092
+ }
1093
+ struct RNMapsPolylineCoordinatesStruct {
1094
+ double latitude{0.0};
1095
+ double longitude{0.0};
1096
+ };
1097
+
1098
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsPolylineCoordinatesStruct &result) {
1099
+ auto map = (std::unordered_map<std::string, RawValue>)value;
1100
+
1101
+ auto tmp_latitude = map.find("latitude");
1102
+ if (tmp_latitude != map.end()) {
1103
+ fromRawValue(context, tmp_latitude->second, result.latitude);
1104
+ }
1105
+ auto tmp_longitude = map.find("longitude");
1106
+ if (tmp_longitude != map.end()) {
1107
+ fromRawValue(context, tmp_longitude->second, result.longitude);
1108
+ }
1109
+ }
1110
+
1111
+ static inline std::string toString(const RNMapsPolylineCoordinatesStruct &value) {
1112
+ return "[Object RNMapsPolylineCoordinatesStruct]";
1113
+ }
1114
+
1115
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, std::vector<RNMapsPolylineCoordinatesStruct> &result) {
1116
+ auto items = (std::vector<RawValue>)value;
1117
+ for (const auto &item : items) {
1118
+ RNMapsPolylineCoordinatesStruct newItem;
1119
+ fromRawValue(context, item, newItem);
1120
+ result.emplace_back(newItem);
1121
+ }
1122
+ }
1123
+
1124
+ class RNMapsPolylineProps final : public ViewProps {
1125
+ public:
1126
+ RNMapsPolylineProps() = default;
1127
+ RNMapsPolylineProps(const PropsParserContext& context, const RNMapsPolylineProps &sourceProps, const RawProps &rawProps);
1128
+
1129
+ #pragma mark - Props
1130
+
1131
+ std::vector<RNMapsPolylineCoordinatesStruct> coordinates{};
1132
+ bool geodesic{false};
1133
+ RNMapsPolylineLineCap lineCap{RNMapsPolylineLineCap::Butt};
1134
+ std::vector<double> lineDashPattern{};
1135
+ RNMapsPolylineLineJoin lineJoin{RNMapsPolylineLineJoin::Miter};
1136
+ SharedColor strokeColor{};
1137
+ std::vector<SharedColor> strokeColors{};
1138
+ Float strokeWidth{0.0};
1139
+ bool tappable{false};
1140
+ };
1141
+
1059
1142
  } // namespace facebook::react
@@ -588,4 +588,8 @@ if ([commandName isEqualToString:@"redraw"]) {
588
588
  #endif
589
589
  }
590
590
 
591
+ @protocol RCTRNMapsPolylineViewProtocol <NSObject>
592
+
593
+ @end
594
+
591
595
  NS_ASSUME_NONNULL_END
@@ -17,5 +17,6 @@ extern const char RNMapsGoogleMapViewComponentName[] = "RNMapsGoogleMapView";
17
17
  extern const char RNMapsGooglePolygonComponentName[] = "RNMapsGooglePolygon";
18
18
  extern const char RNMapsMapViewComponentName[] = "RNMapsMapView";
19
19
  extern const char RNMapsMarkerComponentName[] = "RNMapsMarker";
20
+ extern const char RNMapsPolylineComponentName[] = "RNMapsPolyline";
20
21
 
21
22
  } // namespace facebook::react
@@ -73,4 +73,15 @@ using RNMapsMarkerShadowNode = ConcreteViewShadowNode<
73
73
  RNMapsMarkerEventEmitter,
74
74
  RNMapsMarkerState>;
75
75
 
76
+ JSI_EXPORT extern const char RNMapsPolylineComponentName[];
77
+
78
+ /*
79
+ * `ShadowNode` for <RNMapsPolyline> component.
80
+ */
81
+ using RNMapsPolylineShadowNode = ConcreteViewShadowNode<
82
+ RNMapsPolylineComponentName,
83
+ RNMapsPolylineProps,
84
+ RNMapsPolylineEventEmitter,
85
+ RNMapsPolylineState>;
86
+
76
87
  } // namespace facebook::react
@@ -74,4 +74,16 @@ public:
74
74
  #endif
75
75
  };
76
76
 
77
+ class RNMapsPolylineState {
78
+ public:
79
+ RNMapsPolylineState() = default;
80
+
81
+ #ifdef ANDROID
82
+ RNMapsPolylineState(RNMapsPolylineState const &previousState, folly::dynamic data){};
83
+ folly::dynamic getDynamic() const {
84
+ return {};
85
+ };
86
+ #endif
87
+ };
88
+
77
89
  } // namespace facebook::react
package/lib/MapCallout.js CHANGED
@@ -34,7 +34,6 @@ class MapCallout extends React.Component {
34
34
  render() {
35
35
  const { tooltip = false, alphaHitTest = false } = this.props;
36
36
  const AIRMapCallout = this.getNativeComponent();
37
- console.log('renderCallout ' + AIRMapCallout);
38
37
  return (<AIRMapCallout {...this.props} tooltip={tooltip} alphaHitTest={alphaHitTest} style={[styles.callout, this.props.style]}/>);
39
38
  }
40
39
  }