react-native-maps 0.31.1 → 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 (68) hide show
  1. package/README.md +1 -5
  2. package/android/src/main/AndroidManifest.xml +0 -3
  3. package/android/src/main/java/com/airbnb/android/react/maps/AirMapLocalTile.java +11 -4
  4. package/android/src/main/java/com/airbnb/android/react/maps/AirMapLocalTileManager.java +5 -1
  5. package/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java +2 -41
  6. package/android/src/main/java/com/airbnb/android/react/maps/AirMapTileProvider.java +5 -5
  7. package/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java +0 -32
  8. package/ios/AirGoogleMaps/AIRGoogleMap.m +37 -31
  9. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +0 -95
  10. package/ios/AirMaps/AIRMap.m +0 -7
  11. package/ios/AirMaps/AIRMapManager.m +0 -105
  12. package/lib/AnimatedRegion.d.ts +19 -0
  13. package/lib/AnimatedRegion.js +134 -0
  14. package/lib/Geojson.d.ts +166 -0
  15. package/lib/Geojson.js +165 -0
  16. package/lib/MapCallout.d.ts +40 -0
  17. package/lib/MapCallout.js +51 -0
  18. package/lib/MapCalloutSubview.d.ts +34 -0
  19. package/lib/MapCalloutSubview.js +48 -0
  20. package/lib/MapCircle.d.ts +117 -0
  21. package/lib/MapCircle.js +53 -0
  22. package/lib/MapHeatmap.d.ts +77 -0
  23. package/lib/MapHeatmap.js +59 -0
  24. package/lib/MapLocalTile.d.ts +35 -0
  25. package/lib/MapLocalTile.js +44 -0
  26. package/lib/MapMarker.d.ts +289 -0
  27. package/lib/MapMarker.js +113 -0
  28. package/lib/MapOverlay.d.ts +86 -0
  29. package/lib/MapOverlay.js +63 -0
  30. package/lib/MapPolygon.d.ts +156 -0
  31. package/lib/MapPolygon.js +74 -0
  32. package/lib/MapPolyline.d.ts +156 -0
  33. package/lib/MapPolyline.js +53 -0
  34. package/lib/MapUrlTile.d.ts +134 -0
  35. package/lib/MapUrlTile.js +44 -0
  36. package/lib/MapView.d.ts +825 -0
  37. package/lib/MapView.js +418 -0
  38. package/{src/MapView.web.js → lib/MapView.web.d.ts} +0 -0
  39. package/lib/MapView.web.js +9 -0
  40. package/lib/MapWMSTile.d.ts +116 -0
  41. package/lib/MapWMSTile.js +44 -0
  42. package/lib/ProviderConstants.d.ts +2 -0
  43. package/lib/ProviderConstants.js +5 -0
  44. package/lib/decorateMapComponent.d.ts +35 -0
  45. package/lib/decorateMapComponent.js +80 -0
  46. package/{src/index.js → lib/index.d.ts} +5 -16
  47. package/lib/index.js +66 -0
  48. package/lib/sharedTypes.d.ts +82 -0
  49. package/lib/sharedTypes.js +2 -0
  50. package/package.json +18 -27
  51. package/react-native-google-maps.podspec +1 -1
  52. package/index.d.ts +0 -637
  53. package/src/AnimatedRegion.js +0 -164
  54. package/src/Geojson.js +0 -334
  55. package/src/MapCallout.js +0 -51
  56. package/src/MapCalloutSubview.js +0 -44
  57. package/src/MapCircle.js +0 -150
  58. package/src/MapHeatmap.js +0 -99
  59. package/src/MapLocalTile.js +0 -52
  60. package/src/MapMarker.js +0 -377
  61. package/src/MapOverlay.js +0 -86
  62. package/src/MapPolygon.js +0 -202
  63. package/src/MapPolyline.js +0 -168
  64. package/src/MapUrlTile.js +0 -131
  65. package/src/MapView.js +0 -1160
  66. package/src/MapWMSTile.js +0 -122
  67. package/src/ProviderConstants.js +0 -2
  68. 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,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>
@@ -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
+ }
@@ -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
 
@@ -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
 
@@ -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 {
@@ -163,29 +163,6 @@ RCT_EXPORT_METHOD(animateCamera:(nonnull NSNumber *)reactTag
163
163
  }];
164
164
  }
165
165
 
166
- RCT_EXPORT_METHOD(animateToNavigation:(nonnull NSNumber *)reactTag
167
- withRegion:(MKCoordinateRegion)region
168
- withBearing:(CGFloat)bearing
169
- withAngle:(double)angle
170
- withDuration:(CGFloat)duration)
171
- {
172
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
173
- id view = viewRegistry[reactTag];
174
- if (![view isKindOfClass:[AIRGoogleMap class]]) {
175
- RCTLogError(@"Invalid view returned from registry, expecting AIRGoogleMap, got: %@", view);
176
- } else {
177
- [CATransaction begin];
178
- [CATransaction setAnimationDuration:duration/1000];
179
- AIRGoogleMap *mapView = (AIRGoogleMap *)view;
180
- GMSCameraPosition *camera = [AIRGoogleMap makeGMSCameraPositionFromMap:mapView andMKCoordinateRegion:region];
181
- [mapView animateToCameraPosition:camera];
182
- [mapView animateToViewingAngle:angle];
183
- [mapView animateToBearing:bearing];
184
- [CATransaction commit];
185
- }
186
- }];
187
- }
188
-
189
166
  RCT_EXPORT_METHOD(animateToRegion:(nonnull NSNumber *)reactTag
190
167
  withRegion:(MKCoordinateRegion)region
191
168
  withDuration:(CGFloat)duration)
@@ -207,59 +184,6 @@ RCT_EXPORT_METHOD(animateToRegion:(nonnull NSNumber *)reactTag
207
184
  }];
208
185
  }
209
186
 
210
- RCT_EXPORT_METHOD(animateToCoordinate:(nonnull NSNumber *)reactTag
211
- withRegion:(CLLocationCoordinate2D)latlng
212
- withDuration:(CGFloat)duration)
213
- {
214
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
215
- id view = viewRegistry[reactTag];
216
- if (![view isKindOfClass:[AIRGoogleMap class]]) {
217
- RCTLogError(@"Invalid view returned from registry, expecting AIRGoogleMap, got: %@", view);
218
- } else {
219
- [CATransaction begin];
220
- [CATransaction setAnimationDuration:duration/1000];
221
- [(AIRGoogleMap *)view animateToLocation:latlng];
222
- [CATransaction commit];
223
- }
224
- }];
225
- }
226
-
227
- RCT_EXPORT_METHOD(animateToViewingAngle:(nonnull NSNumber *)reactTag
228
- withAngle:(double)angle
229
- withDuration:(CGFloat)duration)
230
- {
231
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
232
- id view = viewRegistry[reactTag];
233
- if (![view isKindOfClass:[AIRGoogleMap class]]) {
234
- RCTLogError(@"Invalid view returned from registry, expecting AIRGoogleMap, got: %@", view);
235
- } else {
236
- [CATransaction begin];
237
- [CATransaction setAnimationDuration:duration/1000];
238
- AIRGoogleMap *mapView = (AIRGoogleMap *)view;
239
- [mapView animateToViewingAngle:angle];
240
- [CATransaction commit];
241
- }
242
- }];
243
- }
244
-
245
- RCT_EXPORT_METHOD(animateToBearing:(nonnull NSNumber *)reactTag
246
- withBearing:(CGFloat)bearing
247
- withDuration:(CGFloat)duration)
248
- {
249
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
250
- id view = viewRegistry[reactTag];
251
- if (![view isKindOfClass:[AIRGoogleMap class]]) {
252
- RCTLogError(@"Invalid view returned from registry, expecting AIRGoogleMap, got: %@", view);
253
- } else {
254
- [CATransaction begin];
255
- [CATransaction setAnimationDuration:duration/1000];
256
- AIRGoogleMap *mapView = (AIRGoogleMap *)view;
257
- [mapView animateToBearing:bearing];
258
- [CATransaction commit];
259
- }
260
- }];
261
- }
262
-
263
187
  RCT_EXPORT_METHOD(fitToElements:(nonnull NSNumber *)reactTag
264
188
  edgePadding:(nonnull NSDictionary *)edgePadding
265
189
  animated:(BOOL)animated)
@@ -418,25 +342,6 @@ RCT_EXPORT_METHOD(takeSnapshot:(nonnull NSNumber *)reactTag
418
342
  else if ([result isEqualToString:@"base64"]) {
419
343
  callback(@[[NSNull null], [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]]);
420
344
  }
421
- else if ([result isEqualToString:@"legacy"]) {
422
-
423
- // In the initial (iOS only) implementation of takeSnapshot,
424
- // both the uri and the base64 encoded string were returned.
425
- // Returning both is rarely useful and in fact causes a
426
- // performance penalty when only the file URI is desired.
427
- // In that case the base64 encoded string was always marshalled
428
- // over the JS-bridge (which is quite slow).
429
- // A new more flexible API was created to cover this.
430
- // This code should be removed in a future release when the
431
- // old API is fully deprecated.
432
- [data writeToFile:filePath atomically:YES];
433
- NSDictionary *snapshotData = @{
434
- @"uri": filePath,
435
- @"data": [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]
436
- };
437
- callback(@[[NSNull null], snapshotData]);
438
- }
439
-
440
345
  }
441
346
  UIGraphicsEndImageContext();
442
347
  }];
@@ -48,7 +48,6 @@ const NSInteger AIRMapMaxZoomLevel = 20;
48
48
  @implementation AIRMap
49
49
  {
50
50
  UIView *_legalLabel;
51
- CLLocationManager *_locationManager;
52
51
  BOOL _initialRegionSet;
53
52
  BOOL _initialCameraSet;
54
53
 
@@ -350,12 +349,6 @@ const NSInteger AIRMapMaxZoomLevel = 20;
350
349
  - (void)setShowsUserLocation:(BOOL)showsUserLocation
351
350
  {
352
351
  if (self.showsUserLocation != showsUserLocation) {
353
- if (showsUserLocation && !_locationManager) {
354
- _locationManager = [CLLocationManager new];
355
- if ([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
356
- [_locationManager requestWhenInUseAuthorization];
357
- }
358
- }
359
352
  super.showsUserLocation = showsUserLocation;
360
353
  }
361
354
  }
@@ -278,31 +278,6 @@ RCT_EXPORT_METHOD(animateCamera:(nonnull NSNumber *)reactTag
278
278
  }];
279
279
  }
280
280
 
281
-
282
- RCT_EXPORT_METHOD(animateToNavigation:(nonnull NSNumber *)reactTag
283
- withRegion:(MKCoordinateRegion)region
284
- withBearing:(CGFloat)bearing
285
- withAngle:(double)angle
286
- withDuration:(CGFloat)duration)
287
- {
288
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
289
- id view = viewRegistry[reactTag];
290
- if (![view isKindOfClass:[AIRMap class]]) {
291
- RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
292
- } else {
293
- AIRMap *mapView = (AIRMap *)view;
294
- MKMapCamera *mapCamera = [[mapView camera] copy];
295
- [mapCamera setPitch:angle];
296
- [mapCamera setHeading:bearing];
297
-
298
- [AIRMap animateWithDuration:duration/1000 animations:^{
299
- [(AIRMap *)view setRegion:region animated:YES];
300
- [mapView setCamera:mapCamera animated:YES];
301
- }];
302
- }
303
- }];
304
- }
305
-
306
281
  RCT_EXPORT_METHOD(animateToRegion:(nonnull NSNumber *)reactTag
307
282
  withRegion:(MKCoordinateRegion)region
308
283
  withDuration:(CGFloat)duration)
@@ -319,68 +294,6 @@ RCT_EXPORT_METHOD(animateToRegion:(nonnull NSNumber *)reactTag
319
294
  }];
320
295
  }
321
296
 
322
- RCT_EXPORT_METHOD(animateToCoordinate:(nonnull NSNumber *)reactTag
323
- withRegion:(CLLocationCoordinate2D)latlng
324
- withDuration:(CGFloat)duration)
325
- {
326
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
327
- id view = viewRegistry[reactTag];
328
- if (![view isKindOfClass:[AIRMap class]]) {
329
- RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
330
- } else {
331
- AIRMap *mapView = (AIRMap *)view;
332
- MKCoordinateRegion region;
333
- region.span = mapView.region.span;
334
- region.center = latlng;
335
- [AIRMap animateWithDuration:duration/1000 animations:^{
336
- [mapView setRegion:region animated:YES];
337
- }];
338
- }
339
- }];
340
- }
341
-
342
- RCT_EXPORT_METHOD(animateToViewingAngle:(nonnull NSNumber *)reactTag
343
- withAngle:(double)angle
344
- withDuration:(CGFloat)duration)
345
- {
346
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
347
- id view = viewRegistry[reactTag];
348
- if (![view isKindOfClass:[AIRMap class]]) {
349
- RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
350
- } else {
351
- AIRMap *mapView = (AIRMap *)view;
352
-
353
- MKMapCamera *mapCamera = [[mapView camera] copy];
354
- [mapCamera setPitch:angle];
355
-
356
- [AIRMap animateWithDuration:duration/1000 animations:^{
357
- [mapView setCamera:mapCamera animated:YES];
358
- }];
359
- }
360
- }];
361
- }
362
-
363
- RCT_EXPORT_METHOD(animateToBearing:(nonnull NSNumber *)reactTag
364
- withBearing:(CGFloat)bearing
365
- withDuration:(CGFloat)duration)
366
- {
367
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
368
- id view = viewRegistry[reactTag];
369
- if (![view isKindOfClass:[AIRMap class]]) {
370
- RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
371
- } else {
372
- AIRMap *mapView = (AIRMap *)view;
373
-
374
- MKMapCamera *mapCamera = [[mapView camera] copy];
375
- [mapCamera setHeading:bearing];
376
-
377
- [AIRMap animateWithDuration:duration/1000 animations:^{
378
- [mapView setCamera:mapCamera animated:YES];
379
- }];
380
- }
381
- }];
382
- }
383
-
384
297
  RCT_EXPORT_METHOD(fitToElements:(nonnull NSNumber *)reactTag
385
298
  edgePadding:(nonnull NSDictionary *)edgePadding
386
299
  animated:(BOOL)animated)
@@ -677,24 +590,6 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
677
590
  else if ([result isEqualToString:@"base64"]) {
678
591
  callback(@[[NSNull null], [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]]);
679
592
  }
680
- else if ([result isEqualToString:@"legacy"]) {
681
-
682
- // In the initial (iOS only) implementation of takeSnapshot,
683
- // both the uri and the base64 encoded string were returned.
684
- // Returning both is rarely useful and in fact causes a
685
- // performance penalty when only the file URI is desired.
686
- // In that case the base64 encoded string was always marshalled
687
- // over the JS-bridge (which is quite slow).
688
- // A new more flexible API was created to cover this.
689
- // This code should be removed in a future release when the
690
- // old API is fully deprecated.
691
- [data writeToFile:filePath atomically:YES];
692
- NSDictionary *snapshotData = @{
693
- @"uri": filePath,
694
- @"data": [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]
695
- };
696
- callback(@[[NSNull null], snapshotData]);
697
- }
698
593
  }
699
594
  UIGraphicsEndImageContext();
700
595
  }];
@@ -0,0 +1,19 @@
1
+ import { Animated } from 'react-native';
2
+ import { Region } from './sharedTypes';
3
+ declare const AnimatedWithChildren: any;
4
+ declare type Props = Partial<Region> | undefined;
5
+ export default class AnimatedMapRegion extends AnimatedWithChildren {
6
+ constructor(valueIn?: Props);
7
+ setValue(value: Region): void;
8
+ setOffset(offset: Region): void;
9
+ flattenOffset(): void;
10
+ private __getValue;
11
+ private __attach;
12
+ private __detach;
13
+ stopAnimation(callback: (region: Region) => void): void;
14
+ addListener(callback: (region: Region) => void): string;
15
+ removeListener(id: string): void;
16
+ spring(config: Animated.SpringAnimationConfig & Region): Animated.CompositeAnimation;
17
+ timing(config: Animated.TimingAnimationConfig & Region): Animated.CompositeAnimation;
18
+ }
19
+ export {};