react-native-maps 1.8.3 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,9 +49,9 @@ repositories {
49
49
 
50
50
  dependencies {
51
51
  implementation 'com.facebook.react:react-native:+'
52
- implementation "com.google.android.gms:play-services-base:${safeExtGet('playServicesVersion', '18.1.0')}"
53
- implementation "com.google.android.gms:play-services-maps:${safeExtGet('playServicesVersion', '18.0.2')}"
52
+ implementation "com.google.android.gms:play-services-base:${safeExtGet('playServicesVersion', '18.2.0')}"
53
+ implementation "com.google.android.gms:play-services-maps:${safeExtGet('playServicesVersion', '18.2.0')}"
54
54
  implementation "com.google.android.gms:play-services-location:21.0.1"
55
- implementation 'com.google.maps.android:android-maps-utils:3.4.0'
55
+ implementation 'com.google.maps.android:android-maps-utils:3.8.2'
56
56
  implementation "androidx.work:work-runtime:2.7.1"
57
57
  }
@@ -13,6 +13,8 @@ import com.facebook.react.bridge.WritableMap;
13
13
  import com.facebook.react.common.MapBuilder;
14
14
  import com.facebook.react.modules.core.DeviceEventManagerModule;
15
15
  import com.facebook.react.uimanager.LayoutShadowNode;
16
+ import com.facebook.react.uimanager.ReactStylesDiffMap;
17
+ import com.facebook.react.uimanager.StateWrapper;
16
18
  import com.facebook.react.uimanager.ThemedReactContext;
17
19
  import com.facebook.react.uimanager.ViewGroupManager;
18
20
  import com.facebook.react.uimanager.annotations.ReactProp;
@@ -67,9 +69,21 @@ public class MapManager extends ViewGroupManager<MapView> {
67
69
  }
68
70
 
69
71
  @Override
70
- protected MapView createViewInstance(ThemedReactContext context) {
72
+ protected MapView createViewInstance(@NonNull ThemedReactContext context) {
71
73
  return new MapView(context, this.appContext, this, googleMapOptions);
72
74
  }
75
+ @Override
76
+ protected MapView createViewInstance(int reactTag, @NonNull ThemedReactContext reactContext, @Nullable ReactStylesDiffMap initialProps, @Nullable StateWrapper stateWrapper) {
77
+ if (initialProps != null){
78
+ if (initialProps.getString("googleMapId") != null) {
79
+ googleMapOptions.mapId(initialProps.getString("googleMapId"));
80
+ }
81
+ if (initialProps.hasKey("liteMode")) {
82
+ googleMapOptions.liteMode(initialProps.getBoolean("liteMode", false));
83
+ }
84
+ }
85
+ return super.createViewInstance(reactTag, reactContext, initialProps, stateWrapper);
86
+ }
73
87
 
74
88
  private void emitMapError(ThemedReactContext context, String message, String type) {
75
89
  WritableMap error = Arguments.createMap();
@@ -86,6 +100,18 @@ public class MapManager extends ViewGroupManager<MapView> {
86
100
  view.setRegion(region);
87
101
  }
88
102
 
103
+ @ReactProp(name = "liteMode", defaultBoolean = false)
104
+ public void setLiteMode(MapView view, boolean liteMode) {
105
+ googleMapOptions.liteMode(liteMode);
106
+ }
107
+
108
+ @ReactProp(name = "googleMapId")
109
+ public void setGoogleMapId(MapView view, @Nullable String googleMapId) {
110
+ if (googleMapId != null) {
111
+ googleMapOptions.mapId(googleMapId);
112
+ }
113
+ }
114
+
89
115
  @ReactProp(name = "initialRegion")
90
116
  public void setInitialRegion(MapView view, ReadableMap initialRegion) {
91
117
  view.setInitialRegion(initialRegion);
@@ -34,7 +34,6 @@ public class MapsPackage implements ReactPackage {
34
34
  viewManagers.add(new MapGradientPolylineManager(reactContext));
35
35
  viewManagers.add(new MapPolygonManager(reactContext));
36
36
  viewManagers.add(new MapCircleManager(reactContext));
37
- viewManagers.add(new MapLiteManager(reactContext));
38
37
  viewManagers.add(new MapUrlTileManager(reactContext));
39
38
  viewManagers.add(new MapWMSTileManager(reactContext));
40
39
  viewManagers.add(new MapLocalTileManager(reactContext));
@@ -79,6 +79,7 @@
79
79
  + (GMSCameraPosition*)makeGMSCameraPositionFromMap:(GMSMapView *)map andMKCoordinateRegion:(MKCoordinateRegion)region;
80
80
 
81
81
  - (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible;
82
+ - (instancetype) initWithMapId:(NSString *) mapId;
82
83
 
83
84
  @end
84
85
 
@@ -68,11 +68,21 @@ id regionAsJSON(MKCoordinateRegion region) {
68
68
  BOOL _didPrepareMap;
69
69
  BOOL _didCallOnMapReady;
70
70
  BOOL _zoomTapEnabled;
71
+ NSString* _googleMapId;
71
72
  }
72
73
 
73
- - (instancetype)init
74
+ - (instancetype)initWithMapId:(NSString *)mapId
74
75
  {
75
- if ((self = [super init])) {
76
+ if (mapId){
77
+ GMSMapID *mapID = [GMSMapID mapIDWithIdentifier:mapId];
78
+ GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:47.0169
79
+ longitude:-122.336471
80
+ zoom:12];
81
+ self = [super initWithFrame:CGRectZero mapID:mapID camera:camera];
82
+ } else {
83
+ self = [super init];
84
+ }
85
+ if (self) {
76
86
  _reactSubviews = [NSMutableArray new];
77
87
  _markers = [NSMutableArray array];
78
88
  _polygons = [NSMutableArray array];
@@ -105,6 +115,10 @@ id regionAsJSON(MKCoordinateRegion region) {
105
115
  return self;
106
116
  }
107
117
 
118
+ - (instancetype) init {
119
+ return [self initWithMapId:nil];
120
+ }
121
+
108
122
  - (void)dealloc {
109
123
  [self removeObserver:self
110
124
  forKeyPath:@"myLocation"
@@ -292,6 +306,10 @@ id regionAsJSON(MKCoordinateRegion region) {
292
306
  }
293
307
  }
294
308
 
309
+ - (void) setGoogleMapId:(NSString *) googleMapId {
310
+ _googleMapId = googleMapId;
311
+ }
312
+
295
313
  - (void)setCameraProp:(GMSCameraPosition*)camera {
296
314
  _initialCamera = camera;
297
315
  self.camera = camera;
@@ -815,7 +833,7 @@ id regionAsJSON(MKCoordinateRegion region) {
815
833
  @"latitude": @(location.coordinate.latitude),
816
834
  @"longitude": @(location.coordinate.longitude),
817
835
  @"altitude": @(location.altitude),
818
- @"timestamp": @(location.timestamp.timeIntervalSinceReferenceDate * 1000),
836
+ @"timestamp": @(location.timestamp.timeIntervalSince1970 * 1000),
819
837
  @"accuracy": @(location.horizontalAccuracy),
820
838
  @"altitudeAccuracy": @(location.verticalAccuracy),
821
839
  @"speed": @(location.speed),
@@ -10,6 +10,9 @@
10
10
  #import <React/RCTViewManager.h>
11
11
 
12
12
  @interface AIRGoogleMapManager : RCTViewManager
13
+
14
+ @property (nonatomic, strong) NSDictionary *initialProps;
15
+
13
16
  @property (nonatomic) BOOL isGesture;
14
17
 
15
18
  @end
@@ -46,8 +46,11 @@ RCT_EXPORT_MODULE()
46
46
  - (UIView *)view
47
47
  {
48
48
  [GMSServices setMetalRendererEnabled:YES];
49
-
50
- AIRGoogleMap *map = [AIRGoogleMap new];
49
+ NSString* googleMapId = nil;
50
+ if (self.initialProps && self.initialProps[@"googleMapId"]){
51
+ googleMapId = self.initialProps[@"googleMapId"];
52
+ }
53
+ AIRGoogleMap *map = [[AIRGoogleMap alloc] initWithMapId:googleMapId];
51
54
  map.bridge = self.bridge;
52
55
  map.delegate = self;
53
56
  map.isAccessibilityElement = NO;
@@ -67,6 +70,7 @@ RCT_EXPORT_MODULE()
67
70
 
68
71
  RCT_EXPORT_VIEW_PROPERTY(isAccessibilityElement, BOOL)
69
72
  RCT_REMAP_VIEW_PROPERTY(testID, accessibilityIdentifier, NSString)
73
+ RCT_EXPORT_VIEW_PROPERTY(googleMapId, NSString)
70
74
  RCT_EXPORT_VIEW_PROPERTY(initialCamera, GMSCameraPosition)
71
75
  RCT_REMAP_VIEW_PROPERTY(camera, cameraProp, GMSCameraPosition)
72
76
  RCT_EXPORT_VIEW_PROPERTY(initialRegion, MKCoordinateRegion)
@@ -6,7 +6,5 @@
6
6
  #import "AIRMapCoordinate.h"
7
7
 
8
8
 
9
- @implementation AIRMapCoordinate {
10
-
11
- }
12
- @end
9
+ @implementation AIRMapCoordinate
10
+ @end
@@ -915,7 +915,7 @@ static int kDragCenterContext;
915
915
  @"latitude": @(location.coordinate.latitude),
916
916
  @"longitude": @(location.coordinate.longitude),
917
917
  @"altitude": @(location.location.altitude),
918
- @"timestamp": @(location.location.timestamp.timeIntervalSinceReferenceDate * 1000),
918
+ @"timestamp": @(location.location.timestamp.timeIntervalSince1970 * 1000),
919
919
  @"accuracy": @(location.location.horizontalAccuracy),
920
920
  @"altitudeAccuracy": @(location.location.verticalAccuracy),
921
921
  @"speed": @(location.location.speed),
@@ -0,0 +1,13 @@
1
+ //
2
+ // RCTComponentData+Maps.h
3
+ // AirMaps
4
+ //
5
+ // Created by Salah Ghanim on 24.12.23.
6
+ // Copyright © 2023 Christopher. All rights reserved.
7
+ //
8
+
9
+ #import <React/RCTComponentData.h>
10
+
11
+ @interface RCTComponentData (Maps)
12
+
13
+ @end
@@ -0,0 +1,55 @@
1
+ //
2
+ // RCTComponentData+Maps.m
3
+ // AirMaps
4
+ //
5
+ // Created by Salah Ghanim on 24.12.23.
6
+ // Copyright © 2023 Christopher. All rights reserved.
7
+ //
8
+
9
+ #import "RCTComponentData+Maps.h"
10
+ #import <objc/runtime.h>
11
+ #import <Foundation/NSObjCRuntime.h>
12
+
13
+ @implementation RCTComponentData (Maps)
14
+
15
+
16
+ - (void) myCustom_setProps:(NSDictionary<NSString *, id> *)props forShadowView:(RCTShadowView *)shadowView{
17
+ // Pass initialProps to any manager that supports initialProps
18
+ id manager = [self manager];
19
+ if ([manager respondsToSelector:@selector(setInitialProps:)]) {
20
+ [manager performSelector:@selector(setInitialProps:) withObject:props];
21
+ }
22
+
23
+ // Call the original method
24
+ [self myCustom_setProps:props forShadowView:shadowView];
25
+ }
26
+
27
+ + (void)load {
28
+ static dispatch_once_t onceToken;
29
+ dispatch_once(&onceToken, ^{
30
+ Class class = [RCTComponentData class]; // Or the class where the method is defined
31
+
32
+ SEL originalSelector = @selector(setProps:forShadowView:);
33
+ SEL swizzledSelector = @selector(myCustom_setProps:forShadowView:);
34
+
35
+ Method originalMethod = class_getInstanceMethod(class, originalSelector);
36
+ Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
37
+
38
+ BOOL didAddMethod = class_addMethod(class,
39
+ originalSelector,
40
+ method_getImplementation(swizzledMethod),
41
+ method_getTypeEncoding(swizzledMethod));
42
+
43
+ if (didAddMethod) {
44
+ class_replaceMethod(class,
45
+ swizzledSelector,
46
+ method_getImplementation(originalMethod),
47
+ method_getTypeEncoding(originalMethod));
48
+ } else {
49
+ method_exchangeImplementations(originalMethod, swizzledMethod);
50
+ }
51
+ });
52
+ }
53
+
54
+
55
+ @end
@@ -25,6 +25,7 @@
25
25
  2163AA501FEAEDD100BBEC95 /* AIRMapPolylineRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2163AA4F1FEAEDD100BBEC95 /* AIRMapPolylineRenderer.m */; };
26
26
  4C99C9DE2226CF2800A8693E /* AIRWeakTimerReference.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C99C9DD2226CF2800A8693E /* AIRWeakTimerReference.m */; };
27
27
  4C99C9E12226D8C400A8693E /* AIRWeakMapReference.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C99C9E02226D8C400A8693E /* AIRWeakMapReference.m */; };
28
+ 4E0CFBDE2B388F2B0017E126 /* RCTComponentData+Maps.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E0CFBDD2B388F2B0017E126 /* RCTComponentData+Maps.m */; };
28
29
  53D31636202E723B00B55447 /* AIRMapOverlayManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D31635202E723B00B55447 /* AIRMapOverlayManager.m */; };
29
30
  53D3163A202E72FC00B55447 /* AIRMapOverlay.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D31639202E72FC00B55447 /* AIRMapOverlay.m */; };
30
31
  53D3163D202E734F00B55447 /* AIRMapOverlayRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D3163C202E734F00B55447 /* AIRMapOverlayRenderer.m */; };
@@ -112,6 +113,8 @@
112
113
  4C99C9DD2226CF2800A8693E /* AIRWeakTimerReference.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AIRWeakTimerReference.m; sourceTree = "<group>"; };
113
114
  4C99C9DF2226D8C400A8693E /* AIRWeakMapReference.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AIRWeakMapReference.h; sourceTree = "<group>"; };
114
115
  4C99C9E02226D8C400A8693E /* AIRWeakMapReference.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AIRWeakMapReference.m; sourceTree = "<group>"; };
116
+ 4E0CFBDC2B388F2B0017E126 /* RCTComponentData+Maps.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTComponentData+Maps.h"; sourceTree = "<group>"; };
117
+ 4E0CFBDD2B388F2B0017E126 /* RCTComponentData+Maps.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RCTComponentData+Maps.m"; sourceTree = "<group>"; };
115
118
  53D31635202E723B00B55447 /* AIRMapOverlayManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AIRMapOverlayManager.m; sourceTree = "<group>"; };
116
119
  53D31637202E725E00B55447 /* AIRMapOverlayManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AIRMapOverlayManager.h; sourceTree = "<group>"; };
117
120
  53D31638202E72D500B55447 /* AIRMapOverlay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AIRMapOverlay.h; sourceTree = "<group>"; };
@@ -217,6 +220,8 @@
217
220
  11FA5C531C4A1296003AC2EE /* AirMaps */ = {
218
221
  isa = PBXGroup;
219
222
  children = (
223
+ 4E0CFBDC2B388F2B0017E126 /* RCTComponentData+Maps.h */,
224
+ 4E0CFBDD2B388F2B0017E126 /* RCTComponentData+Maps.m */,
220
225
  BE2E4EC72621F63C00CC7F2E /* AIRMapUrlTileCachedOverlay.h */,
221
226
  BE2E4EC82621F63C00CC7F2E /* AIRMapUrlTileCachedOverlay.m */,
222
227
  1125B2BD1C4AD3DA007D0023 /* AIRMap.h */,
@@ -399,6 +404,7 @@
399
404
  A8494E28218891020092506D /* AIRMapWMSTileManager.m in Sources */,
400
405
  1125B2DB1C4AD3DA007D0023 /* AIRMapCallout.m in Sources */,
401
406
  53D31636202E723B00B55447 /* AIRMapOverlayManager.m in Sources */,
407
+ 4E0CFBDE2B388F2B0017E126 /* RCTComponentData+Maps.m in Sources */,
402
408
  1125B2E01C4AD3DA007D0023 /* AIRMapManager.m in Sources */,
403
409
  1125B2E61C4AD3DA007D0023 /* AIRMapPolylineManager.m in Sources */,
404
410
  9B9498DA2017EFB800158761 /* AIRGoogleMapPolygon.m in Sources */,
package/lib/MapView.d.ts CHANGED
@@ -95,6 +95,11 @@ export type MapViewProps = ViewProps & {
95
95
  * @platform Android: Supported
96
96
  */
97
97
  liteMode?: boolean;
98
+ /**
99
+ * https://developers.google.com/maps/documentation/get-map-id
100
+ * google cloud mapId to enable cloud styling and more
101
+ */
102
+ googleMapId?: string;
98
103
  /**
99
104
  * Sets loading background color.
100
105
  *
package/lib/MapView.js CHANGED
@@ -309,6 +309,8 @@ class MapView extends React.Component {
309
309
  initialRegion: null,
310
310
  onChange: this._onChange,
311
311
  onMapReady: this._onMapReady,
312
+ liteMode: this.props.liteMode,
313
+ googleMapId: this.props.googleMapId,
312
314
  ref: this.map,
313
315
  customMapStyleString: this.props.customMapStyle
314
316
  ? JSON.stringify(this.props.customMapStyle)
@@ -329,6 +331,8 @@ class MapView extends React.Component {
329
331
  props = {
330
332
  style: this.props.style,
331
333
  region: null,
334
+ liteMode: this.props.liteMode,
335
+ googleMapId: this.props.googleMapId,
332
336
  initialRegion: this.props.initialRegion || null,
333
337
  initialCamera: this.props.initialCamera,
334
338
  ref: this.map,
@@ -340,11 +344,6 @@ class MapView extends React.Component {
340
344
  : undefined,
341
345
  };
342
346
  }
343
- if (react_native_1.Platform.OS === 'android' && this.props.liteMode) {
344
- return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
345
- <AIRMapLite {...props}/>
346
- </decorateMapComponent_1.ProviderContext.Provider>);
347
- }
348
347
  const AIRMap = getNativeMapComponent(this.props.provider);
349
348
  return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
350
349
  <AIRMap {...props}/>
@@ -364,9 +363,6 @@ else {
364
363
  : (0, decorateMapComponent_1.createNotSupportedComponent)('react-native-maps: AirGoogleMaps dir must be added to your xCode project to support GoogleMaps on iOS.');
365
364
  }
366
365
  const getNativeMapComponent = (provider) => airMaps[provider || 'default'];
367
- const AIRMapLite = react_native_1.UIManager.getViewManagerConfig('AIRMapLite')
368
- ? (0, react_native_1.requireNativeComponent)('AIRMapLite')
369
- : () => null;
370
366
  exports.AnimatedMapView = react_native_1.Animated.createAnimatedComponent(MapView);
371
367
  const enableLatestRenderer = () => {
372
368
  if (react_native_1.Platform.OS !== 'android') {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "main": "lib/index.js",
6
6
  "author": "Leland Richardson <leland.m.richardson@gmail.com>",
7
7
  "homepage": "https://github.com/react-native-maps/react-native-maps#readme",
8
- "version": "1.8.3",
8
+ "version": "1.9.0",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",
@@ -1,20 +0,0 @@
1
- package com.rnmaps.maps;
2
-
3
- import com.facebook.react.bridge.ReactApplicationContext;
4
- import com.google.android.gms.maps.GoogleMapOptions;
5
-
6
- public class MapLiteManager extends MapManager {
7
-
8
- private static final String REACT_CLASS = "AIRMapLite";
9
-
10
- @Override
11
- public String getName() {
12
- return REACT_CLASS;
13
- }
14
-
15
- public MapLiteManager(ReactApplicationContext context) {
16
- super(context);
17
- this.googleMapOptions = new GoogleMapOptions().liteMode(true);
18
- }
19
-
20
- }