react-native-maps 1.21.0-alpha.65 → 1.21.0-alpha.67

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 (34) hide show
  1. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +1 -0
  2. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +1 -0
  3. package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +22 -0
  4. package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +22 -0
  5. package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.cpp +8 -0
  6. package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.h +11 -0
  7. package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI.h +6 -2
  8. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +1 -0
  9. package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +11 -0
  10. package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.h +12 -0
  11. package/android/src/main/java/com/rnmaps/fabric/CalloutManager.java +89 -0
  12. package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +0 -3
  13. package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +16 -1
  14. package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +107 -18
  15. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +5 -1
  16. package/android/src/main/java/com/rnmaps/maps/MapCallout.java +19 -0
  17. package/android/src/main/java/com/rnmaps/maps/MapModule.java +206 -206
  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 +8 -0
  23. package/ios/generated/RNMapsSpecs/Props.h +11 -0
  24. package/ios/generated/RNMapsSpecs/RNMapsSpecs.h +3 -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/ios/generated/RNMapsSpecsJSI.h +6 -2
  29. package/lib/MapCallout.js +1 -0
  30. package/lib/MapView.js +3 -9
  31. package/lib/decorateMapComponent.js +5 -0
  32. package/lib/specs/NativeComponentCallout.d.ts +46 -0
  33. package/lib/specs/NativeComponentCallout.js +9 -0
  34. package/package.json +1 -1
@@ -35,249 +35,249 @@ import java.util.Map;
35
35
  @ReactModule(name = MapModule.NAME)
36
36
  public class MapModule extends ReactContextBaseJavaModule {
37
37
 
38
- public static final String NAME = "AirMapModule";
39
- private static final String SNAPSHOT_RESULT_FILE = "file";
40
- private static final String SNAPSHOT_RESULT_BASE64 = "base64";
41
- private static final String SNAPSHOT_FORMAT_PNG = "png";
42
- private static final String SNAPSHOT_FORMAT_JPG = "jpg";
43
-
44
- public MapModule(ReactApplicationContext reactContext) {
45
- super(reactContext);
46
- }
47
-
48
- @Override
49
- public String getName() {
50
- return NAME;
51
- }
52
-
53
- @Override
54
- public Map<String, Object> getConstants() {
55
- final Map<String, Object> constants = new HashMap<>();
56
- constants.put("legalNotice", "This license information is displayed in Settings > Google > Open Source on any device running Google Play services.");
57
- return constants;
58
- }
59
-
60
- public Activity getActivity() {
61
- return getCurrentActivity();
62
- }
63
-
64
- public static void closeQuietly(Closeable closeable) {
65
- if (closeable == null) return;
66
- try {
67
- closeable.close();
68
- } catch (IOException ignored) {
38
+ public static final String NAME = "AirMapModule";
39
+ public static final String SNAPSHOT_RESULT_FILE = "file";
40
+ public static final String SNAPSHOT_RESULT_BASE64 = "base64";
41
+ public static final String SNAPSHOT_FORMAT_PNG = "png";
42
+ public static final String SNAPSHOT_FORMAT_JPG = "jpg";
43
+
44
+ public MapModule(ReactApplicationContext reactContext) {
45
+ super(reactContext);
69
46
  }
70
- }
71
-
72
- @ReactMethod
73
- public void takeSnapshot(final int tag, final ReadableMap options, final Promise promise) {
74
-
75
- // Parse and verity options
76
- final ReactApplicationContext context = getReactApplicationContext();
77
- final String format = options.hasKey("format") ? options.getString("format") : "png";
78
- final Bitmap.CompressFormat compressFormat =
79
- format.equals(SNAPSHOT_FORMAT_PNG) ? Bitmap.CompressFormat.PNG :
80
- format.equals(SNAPSHOT_FORMAT_JPG) ? Bitmap.CompressFormat.JPEG : null;
81
- final double quality = options.hasKey("quality") ? options.getDouble("quality") : 1.0;
82
- final DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
83
- final Integer width =
84
- options.hasKey("width") ? (int) (displayMetrics.density * options.getDouble("width")) : 0;
85
- final Integer height =
86
- options.hasKey("height") ? (int) (displayMetrics.density * options.getDouble("height")) : 0;
87
- final String result = options.hasKey("result") ? options.getString("result") : "file";
88
-
89
- MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
90
- view.map.snapshot(new GoogleMap.SnapshotReadyCallback() {
91
- public void onSnapshotReady(@Nullable Bitmap snapshot) {
92
-
93
- // Convert image to requested width/height if necessary
94
- if (snapshot == null) {
95
- promise.reject("Failed to generate bitmap, snapshot = null");
96
- return;
97
- }
98
- if ((width != 0) && (height != 0) &&
99
- (width != snapshot.getWidth() || height != snapshot.getHeight())) {
100
- snapshot = Bitmap.createScaledBitmap(snapshot, width, height, true);
101
- }
102
47
 
103
- // Save the snapshot to disk
104
- if (result.equals(SNAPSHOT_RESULT_FILE)) {
105
- File tempFile;
106
- FileOutputStream outputStream;
107
- try {
108
- tempFile =
109
- File.createTempFile("AirMapSnapshot", "." + format, context.getCacheDir());
110
- outputStream = new FileOutputStream(tempFile);
111
- } catch (Exception e) {
112
- promise.reject(e);
113
- return;
114
- }
115
- snapshot.compress(compressFormat, (int) (100.0 * quality), outputStream);
116
- closeQuietly(outputStream);
117
- String uri = Uri.fromFile(tempFile).toString();
118
- promise.resolve(uri);
119
- } else if (result.equals(SNAPSHOT_RESULT_BASE64)) {
120
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
121
- snapshot.compress(compressFormat, (int) (100.0 * quality), outputStream);
122
- closeQuietly(outputStream);
123
- byte[] bytes = outputStream.toByteArray();
124
- String data = Base64.encodeToString(bytes, Base64.NO_WRAP);
125
- promise.resolve(data);
126
- }
127
- }
128
- });
48
+ @Override
49
+ public String getName() {
50
+ return NAME;
51
+ }
129
52
 
130
- return null;
131
- });
53
+ @Override
54
+ public Map<String, Object> getConstants() {
55
+ final Map<String, Object> constants = new HashMap<>();
56
+ constants.put("legalNotice", "This license information is displayed in Settings > Google > Open Source on any device running Google Play services.");
57
+ return constants;
58
+ }
59
+
60
+ public Activity getActivity() {
61
+ return getCurrentActivity();
62
+ }
132
63
 
133
- // Add UI-block so we can get a valid reference to the map-view
64
+ public static void closeQuietly(Closeable closeable) {
65
+ if (closeable == null) return;
66
+ try {
67
+ closeable.close();
68
+ } catch (IOException ignored) {
69
+ }
70
+ }
134
71
 
135
- uiBlock.addToUIManager();
136
- }
72
+ @ReactMethod
73
+ public void takeSnapshot(final int tag, final ReadableMap options, final Promise promise) {
74
+
75
+ // Parse and verity options
76
+ final ReactApplicationContext context = getReactApplicationContext();
77
+ final String format = options.hasKey("format") ? options.getString("format") : "png";
78
+ final Bitmap.CompressFormat compressFormat =
79
+ format.equals(SNAPSHOT_FORMAT_PNG) ? Bitmap.CompressFormat.PNG :
80
+ format.equals(SNAPSHOT_FORMAT_JPG) ? Bitmap.CompressFormat.JPEG : null;
81
+ final double quality = options.hasKey("quality") ? options.getDouble("quality") : 1.0;
82
+ final DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
83
+ final Integer width =
84
+ options.hasKey("width") ? (int) (displayMetrics.density * options.getDouble("width")) : 0;
85
+ final Integer height =
86
+ options.hasKey("height") ? (int) (displayMetrics.density * options.getDouble("height")) : 0;
87
+ final String result = options.hasKey("result") ? options.getString("result") : "file";
88
+
89
+ MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
90
+ view.map.snapshot(new GoogleMap.SnapshotReadyCallback() {
91
+ public void onSnapshotReady(@Nullable Bitmap snapshot) {
92
+
93
+ // Convert image to requested width/height if necessary
94
+ if (snapshot == null) {
95
+ promise.reject("Failed to generate bitmap, snapshot = null");
96
+ return;
97
+ }
98
+ if ((width != 0) && (height != 0) &&
99
+ (width != snapshot.getWidth() || height != snapshot.getHeight())) {
100
+ snapshot = Bitmap.createScaledBitmap(snapshot, width, height, true);
101
+ }
102
+
103
+ // Save the snapshot to disk
104
+ if (result.equals(SNAPSHOT_RESULT_FILE)) {
105
+ File tempFile;
106
+ FileOutputStream outputStream;
107
+ try {
108
+ tempFile =
109
+ File.createTempFile("AirMapSnapshot", "." + format, context.getCacheDir());
110
+ outputStream = new FileOutputStream(tempFile);
111
+ } catch (Exception e) {
112
+ promise.reject(e);
113
+ return;
114
+ }
115
+ snapshot.compress(compressFormat, (int) (100.0 * quality), outputStream);
116
+ closeQuietly(outputStream);
117
+ String uri = Uri.fromFile(tempFile).toString();
118
+ promise.resolve(uri);
119
+ } else if (result.equals(SNAPSHOT_RESULT_BASE64)) {
120
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
121
+ snapshot.compress(compressFormat, (int) (100.0 * quality), outputStream);
122
+ closeQuietly(outputStream);
123
+ byte[] bytes = outputStream.toByteArray();
124
+ String data = Base64.encodeToString(bytes, Base64.NO_WRAP);
125
+ promise.resolve(data);
126
+ }
127
+ }
128
+ });
137
129
 
138
- @ReactMethod
139
- public void getCamera(final int tag, final Promise promise) {
140
- final ReactApplicationContext context = getReactApplicationContext();
130
+ return null;
131
+ });
141
132
 
142
- MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
143
- CameraPosition position = view.map.getCameraPosition();
133
+ // Add UI-block so we can get a valid reference to the map-view
144
134
 
145
- WritableMap centerJson = new WritableNativeMap();
146
- centerJson.putDouble("latitude", position.target.latitude);
147
- centerJson.putDouble("longitude", position.target.longitude);
135
+ uiBlock.addToUIManager();
136
+ }
148
137
 
149
- WritableMap cameraJson = new WritableNativeMap();
150
- cameraJson.putMap("center", centerJson);
151
- cameraJson.putDouble("heading", (double)position.bearing);
152
- cameraJson.putDouble("zoom", (double)position.zoom);
153
- cameraJson.putDouble("pitch", (double)position.tilt);
138
+ @ReactMethod
139
+ public void getCamera(final int tag, final Promise promise) {
140
+ final ReactApplicationContext context = getReactApplicationContext();
154
141
 
155
- promise.resolve(cameraJson);
142
+ MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
143
+ CameraPosition position = view.map.getCameraPosition();
156
144
 
157
- return null;
158
- });
145
+ WritableMap centerJson = new WritableNativeMap();
146
+ centerJson.putDouble("latitude", position.target.latitude);
147
+ centerJson.putDouble("longitude", position.target.longitude);
159
148
 
160
- uiBlock.addToUIManager();
161
- }
149
+ WritableMap cameraJson = new WritableNativeMap();
150
+ cameraJson.putMap("center", centerJson);
151
+ cameraJson.putDouble("heading", (double) position.bearing);
152
+ cameraJson.putDouble("zoom", (double) position.zoom);
153
+ cameraJson.putDouble("pitch", (double) position.tilt);
162
154
 
163
- @ReactMethod
164
- public void getAddressFromCoordinates(final int tag, final ReadableMap coordinate, final Promise promise) {
165
- final ReactApplicationContext context = getReactApplicationContext();
155
+ promise.resolve(cameraJson);
166
156
 
167
- MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, mapView -> {
168
- if (coordinate == null ||
169
- !coordinate.hasKey("latitude") ||
170
- !coordinate.hasKey("longitude")) {
171
- promise.reject("Invalid coordinate format");
172
- return null;
173
- }
174
- Geocoder geocoder = new Geocoder(context);
175
- try {
176
- List<Address> list =
177
- geocoder.getFromLocation(coordinate.getDouble("latitude"),coordinate.getDouble("longitude"),1);
178
- if (list.isEmpty()) {
179
- promise.reject("Can not get address location");
180
157
  return null;
181
- }
182
- Address address = list.get(0);
183
-
184
- WritableMap addressJson = new WritableNativeMap();
185
- addressJson.putString("name", address.getFeatureName());
186
- addressJson.putString("locality", address.getLocality());
187
- addressJson.putString("thoroughfare", address.getThoroughfare());
188
- addressJson.putString("subThoroughfare", address.getSubThoroughfare());
189
- addressJson.putString("subLocality", address.getSubLocality());
190
- addressJson.putString("administrativeArea", address.getAdminArea());
191
- addressJson.putString("subAdministrativeArea", address.getSubAdminArea());
192
- addressJson.putString("postalCode", address.getPostalCode());
193
- addressJson.putString("countryCode", address.getCountryCode());
194
- addressJson.putString("country", address.getCountryName());
195
-
196
- promise.resolve(addressJson);
197
- } catch (IOException e) {
198
- promise.reject("Can not get address location");
199
- }
158
+ });
200
159
 
201
- return null;
202
- });
160
+ uiBlock.addToUIManager();
161
+ }
162
+
163
+ @ReactMethod
164
+ public void getAddressFromCoordinates(final int tag, final ReadableMap coordinate, final Promise promise) {
165
+ final ReactApplicationContext context = getReactApplicationContext();
166
+
167
+ MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, mapView -> {
168
+ if (coordinate == null ||
169
+ !coordinate.hasKey("latitude") ||
170
+ !coordinate.hasKey("longitude")) {
171
+ promise.reject("Invalid coordinate format");
172
+ return null;
173
+ }
174
+ Geocoder geocoder = new Geocoder(context);
175
+ try {
176
+ List<Address> list =
177
+ geocoder.getFromLocation(coordinate.getDouble("latitude"), coordinate.getDouble("longitude"), 1);
178
+ if (list.isEmpty()) {
179
+ promise.reject("Can not get address location");
180
+ return null;
181
+ }
182
+ Address address = list.get(0);
183
+
184
+ WritableMap addressJson = new WritableNativeMap();
185
+ addressJson.putString("name", address.getFeatureName());
186
+ addressJson.putString("locality", address.getLocality());
187
+ addressJson.putString("thoroughfare", address.getThoroughfare());
188
+ addressJson.putString("subThoroughfare", address.getSubThoroughfare());
189
+ addressJson.putString("subLocality", address.getSubLocality());
190
+ addressJson.putString("administrativeArea", address.getAdminArea());
191
+ addressJson.putString("subAdministrativeArea", address.getSubAdminArea());
192
+ addressJson.putString("postalCode", address.getPostalCode());
193
+ addressJson.putString("countryCode", address.getCountryCode());
194
+ addressJson.putString("country", address.getCountryName());
195
+
196
+ promise.resolve(addressJson);
197
+ } catch (IOException e) {
198
+ promise.reject("Can not get address location");
199
+ }
203
200
 
204
- uiBlock.addToUIManager();
205
- }
201
+ return null;
202
+ });
203
+
204
+ uiBlock.addToUIManager();
205
+ }
206
206
 
207
- @ReactMethod
208
- public void pointForCoordinate(final int tag, ReadableMap coordinate, final Promise promise) {
209
- final ReactApplicationContext context = getReactApplicationContext();
210
- final double density = (double) context.getResources().getDisplayMetrics().density;
207
+ @ReactMethod
208
+ public void pointForCoordinate(final int tag, ReadableMap coordinate, final Promise promise) {
209
+ final ReactApplicationContext context = getReactApplicationContext();
210
+ final double density = (double) context.getResources().getDisplayMetrics().density;
211
211
 
212
- final LatLng coord = new LatLng(
213
- coordinate.hasKey("latitude") ? coordinate.getDouble("latitude") : 0.0,
214
- coordinate.hasKey("longitude") ? coordinate.getDouble("longitude") : 0.0
215
- );
212
+ final LatLng coord = new LatLng(
213
+ coordinate.hasKey("latitude") ? coordinate.getDouble("latitude") : 0.0,
214
+ coordinate.hasKey("longitude") ? coordinate.getDouble("longitude") : 0.0
215
+ );
216
216
 
217
- MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
218
- Point pt = view.map.getProjection().toScreenLocation(coord);
217
+ MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
218
+ Point pt = view.map.getProjection().toScreenLocation(coord);
219
219
 
220
- WritableMap ptJson = new WritableNativeMap();
221
- ptJson.putDouble("x", (double)pt.x / density);
222
- ptJson.putDouble("y", (double)pt.y / density);
220
+ WritableMap ptJson = new WritableNativeMap();
221
+ ptJson.putDouble("x", (double) pt.x / density);
222
+ ptJson.putDouble("y", (double) pt.y / density);
223
223
 
224
- promise.resolve(ptJson);
224
+ promise.resolve(ptJson);
225
225
 
226
- return null;
227
- });
226
+ return null;
227
+ });
228
228
 
229
- uiBlock.addToUIManager();
230
- }
229
+ uiBlock.addToUIManager();
230
+ }
231
231
 
232
- @ReactMethod
233
- public void coordinateForPoint(final int tag, ReadableMap point, final Promise promise) {
234
- final ReactApplicationContext context = getReactApplicationContext();
235
- final double density = (double) context.getResources().getDisplayMetrics().density;
232
+ @ReactMethod
233
+ public void coordinateForPoint(final int tag, ReadableMap point, final Promise promise) {
234
+ final ReactApplicationContext context = getReactApplicationContext();
235
+ final double density = (double) context.getResources().getDisplayMetrics().density;
236
236
 
237
- final Point pt = new Point(
238
- point.hasKey("x") ? (int)(point.getDouble("x") * density) : 0,
239
- point.hasKey("y") ? (int)(point.getDouble("y") * density) : 0
240
- );
237
+ final Point pt = new Point(
238
+ point.hasKey("x") ? (int) (point.getDouble("x") * density) : 0,
239
+ point.hasKey("y") ? (int) (point.getDouble("y") * density) : 0
240
+ );
241
241
 
242
- MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
243
- LatLng coord = view.map.getProjection().fromScreenLocation(pt);
242
+ MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
243
+ LatLng coord = view.map.getProjection().fromScreenLocation(pt);
244
244
 
245
- WritableMap coordJson = new WritableNativeMap();
246
- coordJson.putDouble("latitude", coord.latitude);
247
- coordJson.putDouble("longitude", coord.longitude);
245
+ WritableMap coordJson = new WritableNativeMap();
246
+ coordJson.putDouble("latitude", coord.latitude);
247
+ coordJson.putDouble("longitude", coord.longitude);
248
248
 
249
- promise.resolve(coordJson);
249
+ promise.resolve(coordJson);
250
250
 
251
- return null;
252
- });
251
+ return null;
252
+ });
253
253
 
254
- uiBlock.addToUIManager();
255
- }
254
+ uiBlock.addToUIManager();
255
+ }
256
256
 
257
- @ReactMethod
258
- public void getMapBoundaries(final int tag, final Promise promise) {
259
- final ReactApplicationContext context = getReactApplicationContext();
257
+ @ReactMethod
258
+ public void getMapBoundaries(final int tag, final Promise promise) {
259
+ final ReactApplicationContext context = getReactApplicationContext();
260
260
 
261
- MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
262
- double[][] boundaries = view.getMapBoundaries();
261
+ MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
262
+ double[][] boundaries = view.getMapBoundaries();
263
263
 
264
- WritableMap coordinates = new WritableNativeMap();
265
- WritableMap northEastHash = new WritableNativeMap();
266
- WritableMap southWestHash = new WritableNativeMap();
264
+ WritableMap coordinates = new WritableNativeMap();
265
+ WritableMap northEastHash = new WritableNativeMap();
266
+ WritableMap southWestHash = new WritableNativeMap();
267
267
 
268
- northEastHash.putDouble("longitude", boundaries[0][0]);
269
- northEastHash.putDouble("latitude", boundaries[0][1]);
270
- southWestHash.putDouble("longitude", boundaries[1][0]);
271
- southWestHash.putDouble("latitude", boundaries[1][1]);
268
+ northEastHash.putDouble("longitude", boundaries[0][0]);
269
+ northEastHash.putDouble("latitude", boundaries[0][1]);
270
+ southWestHash.putDouble("longitude", boundaries[1][0]);
271
+ southWestHash.putDouble("latitude", boundaries[1][1]);
272
272
 
273
- coordinates.putMap("northEast", northEastHash);
274
- coordinates.putMap("southWest", southWestHash);
273
+ coordinates.putMap("northEast", northEastHash);
274
+ coordinates.putMap("southWest", southWestHash);
275
275
 
276
- promise.resolve(coordinates);
276
+ promise.resolve(coordinates);
277
277
 
278
- return null;
279
- });
278
+ return null;
279
+ });
280
280
 
281
- uiBlock.addToUIManager();
282
- }
281
+ uiBlock.addToUIManager();
282
+ }
283
283
  }
@@ -16,6 +16,7 @@ namespace facebook::react {
16
16
 
17
17
  void RNMapsSpecs_registerComponentDescriptorsFromCodegen(
18
18
  std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
19
+ registry->add(concreteComponentDescriptorProvider<RNMapsCalloutComponentDescriptor>());
19
20
  registry->add(concreteComponentDescriptorProvider<RNMapsGoogleMapViewComponentDescriptor>());
20
21
  registry->add(concreteComponentDescriptorProvider<RNMapsGooglePolygonComponentDescriptor>());
21
22
  registry->add(concreteComponentDescriptorProvider<RNMapsMapViewComponentDescriptor>());
@@ -16,6 +16,7 @@
16
16
 
17
17
  namespace facebook::react {
18
18
 
19
+ using RNMapsCalloutComponentDescriptor = ConcreteComponentDescriptor<RNMapsCalloutShadowNode>;
19
20
  using RNMapsGoogleMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMapsGoogleMapViewShadowNode>;
20
21
  using RNMapsGooglePolygonComponentDescriptor = ConcreteComponentDescriptor<RNMapsGooglePolygonShadowNode>;
21
22
  using RNMapsMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMapsMapViewShadowNode>;
@@ -13,6 +13,28 @@
13
13
 
14
14
  namespace facebook::react {
15
15
 
16
+ void RNMapsCalloutEventEmitter::onPress(OnPress $event) const {
17
+ dispatchEvent("press", [$event=std::move($event)](jsi::Runtime &runtime) {
18
+ auto $payload = jsi::Object(runtime);
19
+ $payload.setProperty(runtime, "action", $event.action);
20
+ $payload.setProperty(runtime, "id", $event.id);
21
+ {
22
+ auto coordinate = jsi::Object(runtime);
23
+ coordinate.setProperty(runtime, "latitude", $event.coordinate.latitude);
24
+ coordinate.setProperty(runtime, "longitude", $event.coordinate.longitude);
25
+ $payload.setProperty(runtime, "coordinate", coordinate);
26
+ }
27
+ {
28
+ auto position = jsi::Object(runtime);
29
+ position.setProperty(runtime, "x", $event.position.x);
30
+ position.setProperty(runtime, "y", $event.position.y);
31
+ $payload.setProperty(runtime, "position", position);
32
+ }
33
+ return $payload;
34
+ });
35
+ }
36
+
37
+
16
38
  void RNMapsGoogleMapViewEventEmitter::onIndoorBuildingFocused(OnIndoorBuildingFocused $event) const {
17
39
  dispatchEvent("indoorBuildingFocused", [$event=std::move($event)](jsi::Runtime &runtime) {
18
40
  auto $payload = jsi::Object(runtime);
@@ -13,6 +13,28 @@
13
13
 
14
14
 
15
15
  namespace facebook::react {
16
+ class RNMapsCalloutEventEmitter : public ViewEventEmitter {
17
+ public:
18
+ using ViewEventEmitter::ViewEventEmitter;
19
+
20
+ struct OnPressCoordinate {
21
+ double latitude;
22
+ double longitude;
23
+ };
24
+
25
+ struct OnPressPosition {
26
+ double x;
27
+ double y;
28
+ };
29
+
30
+ struct OnPress {
31
+ std::string action;
32
+ std::string id;
33
+ OnPressCoordinate coordinate;
34
+ OnPressPosition position;
35
+ };
36
+ void onPress(OnPress value) const;
37
+ };
16
38
  class RNMapsGoogleMapViewEventEmitter : public ViewEventEmitter {
17
39
  public:
18
40
  using ViewEventEmitter::ViewEventEmitter;
@@ -15,6 +15,14 @@
15
15
 
16
16
  namespace facebook::react {
17
17
 
18
+ RNMapsCalloutProps::RNMapsCalloutProps(
19
+ const PropsParserContext &context,
20
+ const RNMapsCalloutProps &sourceProps,
21
+ const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
22
+
23
+ alphaHitTest(convertRawProp(context, rawProps, "alphaHitTest", sourceProps.alphaHitTest, {false})),
24
+ tooltip(convertRawProp(context, rawProps, "tooltip", sourceProps.tooltip, {false}))
25
+ {}
18
26
  RNMapsGoogleMapViewProps::RNMapsGoogleMapViewProps(
19
27
  const PropsParserContext &context,
20
28
  const RNMapsGoogleMapViewProps &sourceProps,
@@ -18,6 +18,17 @@
18
18
 
19
19
  namespace facebook::react {
20
20
 
21
+ class RNMapsCalloutProps final : public ViewProps {
22
+ public:
23
+ RNMapsCalloutProps() = default;
24
+ RNMapsCalloutProps(const PropsParserContext& context, const RNMapsCalloutProps &sourceProps, const RawProps &rawProps);
25
+
26
+ #pragma mark - Props
27
+
28
+ bool alphaHitTest{false};
29
+ bool tooltip{false};
30
+ };
31
+
21
32
  enum class RNMapsGoogleMapViewMapType { Hybrid, MutedStandard, None, Satellite, Standard, Terrain, SatelliteFlyover, HybridFlyover };
22
33
 
23
34
  static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsGoogleMapViewMapType &result) {
@@ -30,6 +30,8 @@
30
30
  #import <optional>
31
31
  #import <vector>
32
32
 
33
+
34
+ NS_ASSUME_NONNULL_BEGIN
33
35
  namespace JS {
34
36
  namespace NativeAirMapsModule {
35
37
  struct LatLng {
@@ -131,4 +133,5 @@ inline double JS::NativeAirMapsModule::Point::y() const
131
133
  id const p = _v[@"y"];
132
134
  return RCTBridgingToDouble(p);
133
135
  }
136
+ NS_ASSUME_NONNULL_END
134
137
  #endif // RNMapsSpecs_H
@@ -12,6 +12,7 @@
12
12
 
13
13
  namespace facebook::react {
14
14
 
15
+ extern const char RNMapsCalloutComponentName[] = "RNMapsCallout";
15
16
  extern const char RNMapsGoogleMapViewComponentName[] = "RNMapsGoogleMapView";
16
17
  extern const char RNMapsGooglePolygonComponentName[] = "RNMapsGooglePolygon";
17
18
  extern const char RNMapsMapViewComponentName[] = "RNMapsMapView";
@@ -18,6 +18,17 @@
18
18
 
19
19
  namespace facebook::react {
20
20
 
21
+ JSI_EXPORT extern const char RNMapsCalloutComponentName[];
22
+
23
+ /*
24
+ * `ShadowNode` for <RNMapsCallout> component.
25
+ */
26
+ using RNMapsCalloutShadowNode = ConcreteViewShadowNode<
27
+ RNMapsCalloutComponentName,
28
+ RNMapsCalloutProps,
29
+ RNMapsCalloutEventEmitter,
30
+ RNMapsCalloutState>;
31
+
21
32
  JSI_EXPORT extern const char RNMapsGoogleMapViewComponentName[];
22
33
 
23
34
  /*
@@ -14,6 +14,18 @@
14
14
 
15
15
  namespace facebook::react {
16
16
 
17
+ class RNMapsCalloutState {
18
+ public:
19
+ RNMapsCalloutState() = default;
20
+
21
+ #ifdef ANDROID
22
+ RNMapsCalloutState(RNMapsCalloutState const &previousState, folly::dynamic data){};
23
+ folly::dynamic getDynamic() const {
24
+ return {};
25
+ };
26
+ #endif
27
+ };
28
+
17
29
  class RNMapsGoogleMapViewState {
18
30
  public:
19
31
  RNMapsGoogleMapViewState() = default;
@@ -176,8 +176,12 @@ public:
176
176
  template <typename T>
177
177
  class JSI_EXPORT NativeAirMapsModuleCxxSpec : public TurboModule {
178
178
  public:
179
- jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
180
- return delegate_.get(rt, propName);
179
+ jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
180
+ return delegate_.create(rt, propName);
181
+ }
182
+
183
+ std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
184
+ return delegate_.getPropertyNames(runtime);
181
185
  }
182
186
 
183
187
  static constexpr std::string_view kModuleName = "RNMapsAirModule";
package/lib/MapCallout.js CHANGED
@@ -34,6 +34,7 @@ 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);
37
38
  return (<AIRMapCallout {...this.props} tooltip={tooltip} alphaHitTest={alphaHitTest} style={[styles.callout, this.props.style]}/>);
38
39
  }
39
40
  }