react-native-maps 0.31.0-beta.6 → 1.0.0-beta.1

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 (78) hide show
  1. package/README.md +1 -5
  2. package/android/build.gradle +31 -2
  3. package/android/src/main/AndroidManifest.xml +0 -3
  4. package/android/src/main/java/com/airbnb/android/react/maps/AirMapCalloutManager.java +2 -2
  5. package/android/src/main/java/com/airbnb/android/react/maps/AirMapLocalTile.java +11 -4
  6. package/android/src/main/java/com/airbnb/android/react/maps/AirMapLocalTileManager.java +5 -1
  7. package/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java +4 -43
  8. package/android/src/main/java/com/airbnb/android/react/maps/AirMapMarker.java +2 -2
  9. package/android/src/main/java/com/airbnb/android/react/maps/AirMapMarkerManager.java +2 -2
  10. package/android/src/main/java/com/airbnb/android/react/maps/AirMapModule.java +1 -2
  11. package/android/src/main/java/com/airbnb/android/react/maps/AirMapOverlayManager.java +2 -2
  12. package/android/src/main/java/com/airbnb/android/react/maps/AirMapPolygonManager.java +2 -2
  13. package/android/src/main/java/com/airbnb/android/react/maps/AirMapPolylineManager.java +2 -2
  14. package/android/src/main/java/com/airbnb/android/react/maps/AirMapTileProvider.java +5 -5
  15. package/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java +0 -32
  16. package/android/src/main/java/com/airbnb/android/react/maps/ImageReader.java +2 -2
  17. package/ios/AirGoogleMaps/AIRGoogleMap.m +37 -31
  18. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +0 -95
  19. package/ios/AirMaps/AIRMap.m +0 -7
  20. package/ios/AirMaps/AIRMapManager.m +0 -105
  21. package/lib/AnimatedRegion.d.ts +19 -0
  22. package/lib/AnimatedRegion.js +134 -0
  23. package/lib/Geojson.d.ts +166 -0
  24. package/lib/Geojson.js +165 -0
  25. package/lib/MapCallout.d.ts +40 -0
  26. package/lib/MapCallout.js +51 -0
  27. package/lib/MapCalloutSubview.d.ts +34 -0
  28. package/lib/MapCalloutSubview.js +48 -0
  29. package/lib/MapCircle.d.ts +117 -0
  30. package/lib/MapCircle.js +53 -0
  31. package/lib/MapHeatmap.d.ts +77 -0
  32. package/lib/MapHeatmap.js +59 -0
  33. package/lib/MapLocalTile.d.ts +35 -0
  34. package/lib/MapLocalTile.js +44 -0
  35. package/lib/MapMarker.d.ts +289 -0
  36. package/lib/MapMarker.js +113 -0
  37. package/lib/MapOverlay.d.ts +86 -0
  38. package/lib/MapOverlay.js +63 -0
  39. package/lib/MapPolygon.d.ts +156 -0
  40. package/lib/MapPolygon.js +74 -0
  41. package/lib/MapPolyline.d.ts +156 -0
  42. package/lib/MapPolyline.js +53 -0
  43. package/lib/MapUrlTile.d.ts +134 -0
  44. package/lib/MapUrlTile.js +44 -0
  45. package/lib/MapView.d.ts +825 -0
  46. package/lib/MapView.js +418 -0
  47. package/{src/MapView.web.js → lib/MapView.web.d.ts} +0 -0
  48. package/lib/MapView.web.js +9 -0
  49. package/lib/MapWMSTile.d.ts +116 -0
  50. package/lib/MapWMSTile.js +44 -0
  51. package/lib/ProviderConstants.d.ts +2 -0
  52. package/lib/ProviderConstants.js +5 -0
  53. package/lib/decorateMapComponent.d.ts +35 -0
  54. package/lib/decorateMapComponent.js +80 -0
  55. package/{src/index.js → lib/index.d.ts} +5 -16
  56. package/lib/index.js +66 -0
  57. package/lib/sharedTypes.d.ts +82 -0
  58. package/lib/sharedTypes.js +2 -0
  59. package/package.json +18 -27
  60. package/react-native-google-maps.podspec +1 -1
  61. package/react-native-maps.podspec +1 -1
  62. package/index.d.ts +0 -637
  63. package/src/AnimatedRegion.js +0 -164
  64. package/src/Geojson.js +0 -334
  65. package/src/MapCallout.js +0 -51
  66. package/src/MapCalloutSubview.js +0 -44
  67. package/src/MapCircle.js +0 -150
  68. package/src/MapHeatmap.js +0 -99
  69. package/src/MapLocalTile.js +0 -52
  70. package/src/MapMarker.js +0 -377
  71. package/src/MapOverlay.js +0 -86
  72. package/src/MapPolygon.js +0 -202
  73. package/src/MapPolyline.js +0 -168
  74. package/src/MapUrlTile.js +0 -131
  75. package/src/MapView.js +0 -1160
  76. package/src/MapWMSTile.js +0 -122
  77. package/src/ProviderConstants.js +0 -2
  78. package/src/decorateMapComponent.js +0 -112
package/README.md CHANGED
@@ -14,11 +14,7 @@ See [Setup Instructions for the Included Example Project](docs/examples-setup.md
14
14
 
15
15
  ## Compatibility
16
16
 
17
- Due to the rapid changes being made in the React Native ecosystem, we are not officially going to
18
- support this module on anything but the latest version of React Native. With that said, we will do
19
- our best to stay compatible with older versions as much that is practical, and the peer dependency
20
- of this requirement is set to `"react-native": "*"` explicitly for this reason. If you are using
21
- an older version of React Native with this module though, some features may be buggy.
17
+ `react-native-maps` requires `react-native >= 0.64.3`.
22
18
 
23
19
  ## Component API
24
20
 
@@ -1,9 +1,24 @@
1
- apply plugin: 'com.android.library'
2
-
3
1
  def safeExtGet(prop, fallback) {
4
2
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5
3
  }
6
4
 
5
+ buildscript {
6
+ // The Android Gradle plugin is only required when opening the android folder stand-alone.
7
+ // This avoids unnecessary downloads and potential conflicts when the library is included as a
8
+ // module dependency in an application project.
9
+ if (project == rootProject) {
10
+ repositories {
11
+ google()
12
+ mavenCentral()
13
+ }
14
+ dependencies {
15
+ classpath("com.android.tools.build:gradle:4.2.2")
16
+ }
17
+ }
18
+ }
19
+
20
+ apply plugin: 'com.android.library'
21
+
7
22
  android {
8
23
  compileSdkVersion safeExtGet('compileSdkVersion', 30)
9
24
 
@@ -13,6 +28,20 @@ android {
13
28
  }
14
29
  }
15
30
 
31
+ repositories {
32
+ mavenLocal()
33
+ mavenCentral()
34
+ maven {
35
+ // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
36
+ url "$rootDir/../node_modules/react-native/android"
37
+ }
38
+ maven {
39
+ // Android JSC is installed from npm
40
+ url "$rootDir/../node_modules/jsc-android/dist"
41
+ }
42
+ google()
43
+ }
44
+
16
45
  dependencies {
17
46
  def work_version = safeExtGet('targetSdkVersion', 27) < 31 ? "2.5.0" : "2.7.1"
18
47
  implementation 'com.facebook.react:react-native:+'
@@ -1,6 +1,3 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
2
  package="com.airbnb.android.react.maps" >
4
- <uses-permission android:name="android.permission.INTERNET" />
5
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
6
3
  </manifest>
@@ -1,5 +1,7 @@
1
1
  package com.airbnb.android.react.maps;
2
2
 
3
+ import androidx.annotation.Nullable;
4
+
3
5
  import com.facebook.react.common.MapBuilder;
4
6
  import com.facebook.react.uimanager.LayoutShadowNode;
5
7
  import com.facebook.react.uimanager.ThemedReactContext;
@@ -8,8 +10,6 @@ import com.facebook.react.uimanager.annotations.ReactProp;
8
10
 
9
11
  import java.util.Map;
10
12
 
11
- import javax.annotation.Nullable;
12
-
13
13
  public class AirMapCalloutManager extends ViewGroupManager<AirMapCallout> {
14
14
 
15
15
  @Override
@@ -20,11 +20,13 @@ public class AirMapLocalTile extends AirMapFeature {
20
20
  private static final int BUFFER_SIZE = 16 * 1024;
21
21
  private int tileSize;
22
22
  private String pathTemplate;
23
+ private boolean useAssets;
23
24
 
24
25
 
25
- public AIRMapLocalTileProvider(int tileSizet, String pathTemplate) {
26
+ public AIRMapLocalTileProvider(int tileSizet, String pathTemplate, boolean useAssets) {
26
27
  this.tileSize = tileSizet;
27
28
  this.pathTemplate = pathTemplate;
29
+ this.useAssets = useAssets;
28
30
  }
29
31
 
30
32
  @Override
@@ -44,10 +46,10 @@ public class AirMapLocalTile extends AirMapFeature {
44
46
  private byte[] readTileImage(int x, int y, int zoom) {
45
47
  InputStream in = null;
46
48
  ByteArrayOutputStream buffer = null;
47
- File file = new File(getTileFilename(x, y, zoom));
49
+ String tileFilename = getTileFilename(x, y, zoom);
48
50
 
49
51
  try {
50
- in = new FileInputStream(file);
52
+ in = useAssets ? getContext().getAssets().open(tileFilename) : new FileInputStream(tileFilename);
51
53
  buffer = new ByteArrayOutputStream();
52
54
 
53
55
  int nRead;
@@ -87,6 +89,7 @@ public class AirMapLocalTile extends AirMapFeature {
87
89
  private String pathTemplate;
88
90
  private float tileSize;
89
91
  private float zIndex;
92
+ private boolean useAssets;
90
93
 
91
94
  public AirMapLocalTile(Context context) {
92
95
  super(context);
@@ -116,6 +119,10 @@ public class AirMapLocalTile extends AirMapFeature {
116
119
  }
117
120
  }
118
121
 
122
+ public void setUseAssets(boolean useAssets) {
123
+ this.useAssets = useAssets;
124
+ }
125
+
119
126
  public TileOverlayOptions getTileOverlayOptions() {
120
127
  if (tileOverlayOptions == null) {
121
128
  tileOverlayOptions = createTileOverlayOptions();
@@ -126,7 +133,7 @@ public class AirMapLocalTile extends AirMapFeature {
126
133
  private TileOverlayOptions createTileOverlayOptions() {
127
134
  TileOverlayOptions options = new TileOverlayOptions();
128
135
  options.zIndex(zIndex);
129
- this.tileProvider = new AirMapLocalTile.AIRMapLocalTileProvider((int)this.tileSize, this.pathTemplate);
136
+ this.tileProvider = new AirMapLocalTile.AIRMapLocalTileProvider((int)this.tileSize, this.pathTemplate, this.useAssets);
130
137
  options.tileProvider(this.tileProvider);
131
138
  return options;
132
139
  }
@@ -53,4 +53,8 @@ public class AirMapLocalTileManager extends ViewGroupManager<AirMapLocalTile> {
53
53
  view.setZIndex(zIndex);
54
54
  }
55
55
 
56
- }
56
+ @ReactProp(name = "useAssets", defaultBoolean = false)
57
+ public void setUseAssets(AirMapLocalTile view, boolean useAssets) {
58
+ view.setUseAssets(useAssets);
59
+ }
60
+ }
@@ -2,6 +2,8 @@ package com.airbnb.android.react.maps;
2
2
 
3
3
  import android.view.View;
4
4
 
5
+ import androidx.annotation.Nullable;
6
+
5
7
  import com.facebook.react.bridge.Arguments;
6
8
  import com.facebook.react.bridge.ReactApplicationContext;
7
9
  import com.facebook.react.bridge.ReadableArray;
@@ -24,8 +26,6 @@ import com.google.android.gms.maps.model.MapStyleOptions;
24
26
  import java.util.HashMap;
25
27
  import java.util.Map;
26
28
 
27
- import javax.annotation.Nullable;
28
-
29
29
  public class AirMapManager extends ViewGroupManager<AirMapView> {
30
30
 
31
31
  private static final String REACT_CLASS = "AIRMap";
@@ -314,17 +314,6 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
314
314
  view.animateToCamera(camera, duration);
315
315
  break;
316
316
 
317
- case ANIMATE_TO_NAVIGATION:
318
- region = args.getMap(0);
319
- lng = region.getDouble("longitude");
320
- lat = region.getDouble("latitude");
321
- LatLng location = new LatLng(lat, lng);
322
- bearing = (float)args.getDouble(1);
323
- angle = (float)args.getDouble(2);
324
- duration = args.getInt(3);
325
- view.animateToNavigation(location, bearing, angle, duration);
326
- break;
327
-
328
317
  case ANIMATE_TO_REGION:
329
318
  region = args.getMap(0);
330
319
  duration = args.getInt(1);
@@ -339,26 +328,6 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
339
328
  view.animateToRegion(bounds, duration);
340
329
  break;
341
330
 
342
- case ANIMATE_TO_COORDINATE:
343
- region = args.getMap(0);
344
- duration = args.getInt(1);
345
- lng = region.getDouble("longitude");
346
- lat = region.getDouble("latitude");
347
- view.animateToCoordinate(new LatLng(lat, lng), duration);
348
- break;
349
-
350
- case ANIMATE_TO_VIEWING_ANGLE:
351
- angle = (float)args.getDouble(0);
352
- duration = args.getInt(1);
353
- view.animateToViewingAngle(angle, duration);
354
- break;
355
-
356
- case ANIMATE_TO_BEARING:
357
- bearing = (float)args.getDouble(0);
358
- duration = args.getInt(1);
359
- view.animateToBearing(bearing, duration);
360
- break;
361
-
362
331
  case FIT_TO_ELEMENTS:
363
332
  view.fitToElements(args.getMap(0), args.getBoolean(1));
364
333
  break;
@@ -421,13 +390,9 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
421
390
  "setCamera", SET_CAMERA,
422
391
  "animateCamera", ANIMATE_CAMERA,
423
392
  "animateToRegion", ANIMATE_TO_REGION,
424
- "animateToCoordinate", ANIMATE_TO_COORDINATE,
425
- "animateToViewingAngle", ANIMATE_TO_VIEWING_ANGLE,
426
- "animateToBearing", ANIMATE_TO_BEARING,
427
393
  "fitToElements", FIT_TO_ELEMENTS,
428
394
  "fitToSuppliedMarkers", FIT_TO_SUPPLIED_MARKERS,
429
- "fitToCoordinates", FIT_TO_COORDINATES,
430
- "animateToNavigation", ANIMATE_TO_NAVIGATION
395
+ "fitToCoordinates", FIT_TO_COORDINATES
431
396
  );
432
397
 
433
398
  map.putAll(MapBuilder.of(
@@ -439,7 +404,7 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
439
404
  }
440
405
 
441
406
  public static <K, V> Map<K, V> CreateMap(
442
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) {
407
+ K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
443
408
  Map map = new HashMap<K, V>();
444
409
  map.put(k1, v1);
445
410
  map.put(k2, v2);
@@ -447,10 +412,6 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
447
412
  map.put(k4, v4);
448
413
  map.put(k5, v5);
449
414
  map.put(k6, v6);
450
- map.put(k7, v7);
451
- map.put(k8, v8);
452
- map.put(k9, v9);
453
- map.put(k10, v10);
454
415
  return map;
455
416
  }
456
417
 
@@ -14,6 +14,8 @@ import android.animation.ObjectAnimator;
14
14
  import android.util.Property;
15
15
  import android.animation.TypeEvaluator;
16
16
 
17
+ import androidx.annotation.Nullable;
18
+
17
19
  import com.facebook.common.references.CloseableReference;
18
20
  import com.facebook.datasource.DataSource;
19
21
  import com.facebook.drawee.backends.pipeline.Fresco;
@@ -38,8 +40,6 @@ import com.google.android.gms.maps.model.LatLng;
38
40
  import com.google.android.gms.maps.model.Marker;
39
41
  import com.google.android.gms.maps.model.MarkerOptions;
40
42
 
41
- import javax.annotation.Nullable;
42
-
43
43
  public class AirMapMarker extends AirMapFeature {
44
44
 
45
45
  private MarkerOptions markerOptions;
@@ -4,6 +4,8 @@ import android.graphics.Bitmap;
4
4
  import android.graphics.Color;
5
5
  import android.view.View;
6
6
 
7
+ import androidx.annotation.Nullable;
8
+
7
9
  import com.facebook.react.bridge.ReadableArray;
8
10
  import com.facebook.react.bridge.ReadableMap;
9
11
  import com.facebook.react.common.MapBuilder;
@@ -20,8 +22,6 @@ import java.util.Map;
20
22
  import java.util.WeakHashMap;
21
23
  import java.util.concurrent.ConcurrentHashMap;
22
24
 
23
- import javax.annotation.Nullable;
24
-
25
25
  public class AirMapMarkerManager extends ViewGroupManager<AirMapMarker> {
26
26
 
27
27
  private static final int SHOW_INFO_WINDOW = 1;
@@ -10,6 +10,7 @@ import android.util.Base64;
10
10
  import android.util.DisplayMetrics;
11
11
  import android.util.Log;
12
12
 
13
+ import androidx.annotation.Nullable;
13
14
  import androidx.annotation.NonNull;
14
15
 
15
16
  import com.facebook.react.bridge.Promise;
@@ -39,8 +40,6 @@ import java.util.List;
39
40
  import java.util.Map;
40
41
  import java.util.HashMap;
41
42
 
42
- import javax.annotation.Nullable;
43
-
44
43
  @ReactModule(name = AirMapModule.NAME)
45
44
  public class AirMapModule extends ReactContextBaseJavaModule {
46
45
 
@@ -5,6 +5,8 @@ import android.os.Build;
5
5
  import android.util.DisplayMetrics;
6
6
  import android.view.WindowManager;
7
7
 
8
+ import androidx.annotation.Nullable;
9
+
8
10
  import com.facebook.react.bridge.ReactApplicationContext;
9
11
  import com.facebook.react.bridge.ReadableArray;
10
12
  import com.facebook.react.common.MapBuilder;
@@ -14,8 +16,6 @@ import com.facebook.react.uimanager.annotations.ReactProp;
14
16
 
15
17
  import java.util.Map;
16
18
 
17
- import javax.annotation.Nullable;
18
-
19
19
  public class AirMapOverlayManager extends ViewGroupManager<AirMapOverlay> {
20
20
  private final DisplayMetrics metrics;
21
21
 
@@ -6,6 +6,8 @@ import android.os.Build;
6
6
  import android.util.DisplayMetrics;
7
7
  import android.view.WindowManager;
8
8
 
9
+ import androidx.annotation.Nullable;
10
+
9
11
  import com.facebook.react.bridge.ReactApplicationContext;
10
12
  import com.facebook.react.bridge.ReadableArray;
11
13
  import com.facebook.react.common.MapBuilder;
@@ -15,8 +17,6 @@ import com.facebook.react.uimanager.annotations.ReactProp;
15
17
 
16
18
  import java.util.Map;
17
19
 
18
- import javax.annotation.Nullable;
19
-
20
20
  public class AirMapPolygonManager extends ViewGroupManager<AirMapPolygon> {
21
21
  private final DisplayMetrics metrics;
22
22
 
@@ -6,6 +6,8 @@ import android.os.Build;
6
6
  import android.util.DisplayMetrics;
7
7
  import android.view.WindowManager;
8
8
 
9
+ import androidx.annotation.Nullable;
10
+
9
11
  import com.facebook.react.bridge.ReactApplicationContext;
10
12
  import com.facebook.react.bridge.ReadableArray;
11
13
  import com.facebook.react.common.MapBuilder;
@@ -19,8 +21,6 @@ import com.google.android.gms.maps.model.SquareCap;
19
21
 
20
22
  import java.util.Map;
21
23
 
22
- import javax.annotation.Nullable;
23
-
24
24
  public class AirMapPolylineManager extends ViewGroupManager<AirMapPolyline> {
25
25
  private final DisplayMetrics metrics;
26
26
 
@@ -171,10 +171,10 @@ public class AirMapTileProvider implements TileProvider {
171
171
  if (this.tileCachePath != null) {
172
172
  image = readTileImage(x, y, zoom);
173
173
  if (image != null) {
174
- Log.d("urlTile: tile cache HIT for ", Integer.toString(zoom) +
174
+ Log.d("urlTile", "tile cache HIT for " + Integer.toString(zoom) +
175
175
  "/" + Integer.toString(x) + "/" + Integer.toString(y));
176
176
  } else {
177
- Log.d("urlTile: tile cache MISS for ", Integer.toString(zoom) +
177
+ Log.d("urlTile", "tile cache MISS for " + Integer.toString(zoom) +
178
178
  "/" + Integer.toString(x) + "/" + Integer.toString(y));
179
179
  }
180
180
  if (image != null && !this.offlineMode) {
@@ -212,10 +212,10 @@ public class AirMapTileProvider implements TileProvider {
212
212
  if (this.tileCachePath != null) {
213
213
  image = readTileImage(x, y, zoom);
214
214
  if (image != null) {
215
- Log.d("urlTile: tile cache fetch HIT for ", Integer.toString(zoom) +
215
+ Log.d("urlTile","tile cache fetch HIT for " + Integer.toString(zoom) +
216
216
  "/" + Integer.toString(x) + "/" + Integer.toString(y));
217
217
  } else {
218
- Log.d("urlTile: tile cache fetch MISS for ", Integer.toString(zoom) +
218
+ Log.d("urlTile","tile cache fetch MISS for " + Integer.toString(zoom) +
219
219
  "/" + Integer.toString(x) + "/" + Integer.toString(y));
220
220
  }
221
221
  }
@@ -229,7 +229,7 @@ public class AirMapTileProvider implements TileProvider {
229
229
  Log.d("urlTile", "Normal fetch");
230
230
  image = fetchTile(x, y, zoom);
231
231
  if (image == null) {
232
- Log.d("urlTile: tile fetch TIMEOUT / FAIL for ", Integer.toString(zoom) +
232
+ Log.d("urlTile", "tile fetch TIMEOUT / FAIL for " + Integer.toString(zoom) +
233
233
  "/" + Integer.toString(x) + "/" + Integer.toString(y));
234
234
  }
235
235
  }
@@ -799,43 +799,11 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
799
799
  }
800
800
  }
801
801
 
802
- public void animateToNavigation(LatLng location, float bearing, float angle, int duration) {
803
- if (map == null) return;
804
- CameraPosition cameraPosition = new CameraPosition.Builder(map.getCameraPosition())
805
- .bearing(bearing)
806
- .tilt(angle)
807
- .target(location)
808
- .build();
809
- map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), duration, null);
810
- }
811
-
812
802
  public void animateToRegion(LatLngBounds bounds, int duration) {
813
803
  if (map == null) return;
814
804
  map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0), duration, null);
815
805
  }
816
806
 
817
- public void animateToViewingAngle(float angle, int duration) {
818
- if (map == null) return;
819
-
820
- CameraPosition cameraPosition = new CameraPosition.Builder(map.getCameraPosition())
821
- .tilt(angle)
822
- .build();
823
- map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), duration, null);
824
- }
825
-
826
- public void animateToBearing(float bearing, int duration) {
827
- if (map == null) return;
828
- CameraPosition cameraPosition = new CameraPosition.Builder(map.getCameraPosition())
829
- .bearing(bearing)
830
- .build();
831
- map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), duration, null);
832
- }
833
-
834
- public void animateToCoordinate(LatLng coordinate, int duration) {
835
- if (map == null) return;
836
- map.animateCamera(CameraUpdateFactory.newLatLng(coordinate), duration, null);
837
- }
838
-
839
807
  public void fitToElements(ReadableMap edgePadding, boolean animated) {
840
808
  if (map == null) return;
841
809
 
@@ -7,6 +7,8 @@ import android.graphics.BitmapFactory;
7
7
  import android.graphics.drawable.Animatable;
8
8
  import android.net.Uri;
9
9
 
10
+ import androidx.annotation.Nullable;
11
+
10
12
  import com.facebook.common.references.CloseableReference;
11
13
  import com.facebook.datasource.DataSource;
12
14
  import com.facebook.drawee.backends.pipeline.Fresco;
@@ -26,8 +28,6 @@ import com.facebook.imagepipeline.request.ImageRequestBuilder;
26
28
  import com.google.android.gms.maps.model.BitmapDescriptor;
27
29
  import com.google.android.gms.maps.model.BitmapDescriptorFactory;
28
30
 
29
- import javax.annotation.Nullable;
30
-
31
31
  public class ImageReader {
32
32
 
33
33
  private final ImageReadable imp;
@@ -62,9 +62,10 @@ id regionAsJSON(MKCoordinateRegion region) {
62
62
  NSMutableArray<UIView *> *_reactSubviews;
63
63
  MKCoordinateRegion _initialRegion;
64
64
  MKCoordinateRegion _region;
65
- BOOL _initialCameraSetOnLoad;
65
+ BOOL _initialRegionSet;
66
+ BOOL _initialCameraSet;
67
+ BOOL _didPrepareMap;
66
68
  BOOL _didCallOnMapReady;
67
- BOOL _didMoveToWindow;
68
69
  BOOL _zoomTapEnabled;
69
70
  }
70
71
 
@@ -83,9 +84,10 @@ id regionAsJSON(MKCoordinateRegion region) {
83
84
  _cameraProp = nil;
84
85
  _initialRegion = MKCoordinateRegionMake(CLLocationCoordinate2DMake(0.0, 0.0), MKCoordinateSpanMake(0.0, 0.0));
85
86
  _region = MKCoordinateRegionMake(CLLocationCoordinate2DMake(0.0, 0.0), MKCoordinateSpanMake(0.0, 0.0));
86
- _initialCameraSetOnLoad = false;
87
+ _initialRegionSet = false;
88
+ _initialCameraSet = false;
89
+ _didPrepareMap = false;
87
90
  _didCallOnMapReady = false;
88
- _didMoveToWindow = false;
89
91
  _zoomTapEnabled = YES;
90
92
 
91
93
  // Listen to the myLocation property of GMSMapView.
@@ -245,36 +247,20 @@ id regionAsJSON(MKCoordinateRegion region) {
245
247
  ];
246
248
  }
247
249
 
248
- - (void)didMoveToWindow {
249
- if (_didMoveToWindow) return;
250
- _didMoveToWindow = true;
251
-
252
- if (_initialCamera != nil) {
253
- self.camera = _initialCamera;
254
- }
255
- else if (_initialRegion.span.latitudeDelta != 0.0 &&
256
- _initialRegion.span.longitudeDelta != 0.0) {
257
- self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:_initialRegion];
258
- } else if (_region.span.latitudeDelta != 0.0 &&
259
- _region.span.longitudeDelta != 0.0) {
260
- self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:_region];
261
- }
262
-
263
- [super didMoveToWindow];
264
- }
265
-
266
250
  - (void)setInitialRegion:(MKCoordinateRegion)initialRegion {
267
- if (_initialCameraSetOnLoad) return;
268
251
  _initialRegion = initialRegion;
269
- _initialCameraSetOnLoad = _didMoveToWindow;
270
- self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:initialRegion];
252
+ if(!_initialRegionSet && _didPrepareMap){
253
+ self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:initialRegion];
254
+ _initialRegionSet = true;
255
+ }
271
256
  }
272
257
 
273
258
  - (void)setInitialCamera:(GMSCameraPosition*)initialCamera {
274
- if (_initialCameraSetOnLoad) return;
275
259
  _initialCamera = initialCamera;
276
- _initialCameraSetOnLoad = _didMoveToWindow;
277
- self.camera = initialCamera;
260
+ if(!_initialCameraSet && _didPrepareMap){
261
+ self.camera = initialCamera;
262
+ _initialCameraSet = true;
263
+ }
278
264
  }
279
265
 
280
266
  - (void)setRegion:(MKCoordinateRegion)region {
@@ -288,14 +274,34 @@ id regionAsJSON(MKCoordinateRegion region) {
288
274
  self.camera = camera;
289
275
  }
290
276
 
277
+ - (void)setOnMapReady:(RCTBubblingEventBlock)onMapReady {
278
+ _onMapReady = onMapReady;
279
+ if(!_didCallOnMapReady && _didPrepareMap) {
280
+ self.onMapReady(@{});
281
+ _didCallOnMapReady = true;
282
+ }
283
+ }
291
284
 
292
285
  - (void)didPrepareMap {
293
286
  UIView* mapView = [self valueForKey:@"mapView"]; //GMSVectorMapView
294
287
  [self overrideGestureRecognizersForView:mapView];
295
288
 
296
- if (_didCallOnMapReady) return;
297
- _didCallOnMapReady = true;
298
- if (self.onMapReady) self.onMapReady(@{});
289
+ if(!_didPrepareMap && !_initialRegionSet && !_initialCameraSet){
290
+ if(_initialRegion.span.latitudeDelta != 0.0 && _initialRegion.span.longitudeDelta != 0.0){
291
+ self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:_initialRegion];
292
+ _initialRegionSet = true;
293
+ } else if(_initialCamera != nil) {
294
+ self.camera = _initialCamera;
295
+ _initialCameraSet = true;
296
+ } else if(_region.span.latitudeDelta != 0.0 && _region.span.longitudeDelta != 0.0) {
297
+ self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:_region];
298
+ }
299
+ }
300
+ if (!_didCallOnMapReady && self.onMapReady) {
301
+ self.onMapReady(@{});
302
+ _didCallOnMapReady = true;
303
+ }
304
+ _didPrepareMap = true;
299
305
  }
300
306
 
301
307
  - (void)mapViewDidFinishTileRendering {