react-native-maps 1.0.0-beta.9 → 1.1.0-beta.2

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.
@@ -45,9 +45,9 @@ repositories {
45
45
  dependencies {
46
46
  def work_version = safeExtGet('targetSdkVersion', 27) < 31 ? "2.5.0" : "2.7.1"
47
47
  implementation 'com.facebook.react:react-native:+'
48
- implementation "com.google.android.gms:play-services-base:${safeExtGet('playServicesVersion', '18.0.1')}"
48
+ implementation "com.google.android.gms:play-services-base:${safeExtGet('playServicesVersion', '18.1.0')}"
49
49
  implementation "com.google.android.gms:play-services-maps:${safeExtGet('playServicesVersion', '18.0.2')}"
50
- implementation "com.google.android.gms:play-services-location:19.0.1"
50
+ implementation "com.google.android.gms:play-services-location:20.0.0"
51
51
  implementation 'com.google.maps.android:android-maps-utils:0.5'
52
52
  implementation "androidx.work:work-runtime:$work_version"
53
53
  }
@@ -16,7 +16,7 @@ import com.facebook.react.uimanager.ThemedReactContext;
16
16
  import com.facebook.react.uimanager.ViewGroupManager;
17
17
  import com.facebook.react.uimanager.annotations.ReactProp;
18
18
  import com.facebook.react.uimanager.events.RCTEventEmitter;
19
- import com.google.android.gms.location.LocationRequest;
19
+ import com.google.android.gms.location.Priority;
20
20
  import com.google.android.gms.maps.GoogleMap;
21
21
  import com.google.android.gms.maps.GoogleMapOptions;
22
22
  import com.google.android.gms.maps.model.LatLng;
@@ -52,10 +52,10 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
52
52
  );
53
53
 
54
54
  private final Map<String, Integer> MY_LOCATION_PRIORITY = MapBuilder.of(
55
- "balanced", LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY,
56
- "high", LocationRequest.PRIORITY_HIGH_ACCURACY,
57
- "low", LocationRequest.PRIORITY_LOW_POWER,
58
- "passive", LocationRequest.PRIORITY_NO_POWER
55
+ "balanced", Priority.PRIORITY_BALANCED_POWER_ACCURACY,
56
+ "high", Priority.PRIORITY_HIGH_ACCURACY,
57
+ "low", Priority.PRIORITY_LOW_POWER,
58
+ "passive", Priority.PRIORITY_PASSIVE
59
59
  );
60
60
 
61
61
  private final ReactApplicationContext appContext;
@@ -123,7 +123,7 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
123
123
 
124
124
  @ReactProp(name = "customMapStyleString")
125
125
  public void setMapStyle(AirMapView view, @Nullable String customMapStyleString) {
126
- view.map.setMapStyle(new MapStyleOptions(customMapStyleString));
126
+ view.setMapStyle(customMapStyleString);
127
127
  }
128
128
 
129
129
  @ReactProp(name = "mapPadding")
@@ -9,6 +9,7 @@ import android.graphics.PorterDuff;
9
9
  import android.graphics.Rect;
10
10
  import android.os.Build;
11
11
 
12
+ import androidx.annotation.Nullable;
12
13
  import androidx.core.content.PermissionChecker;
13
14
  import androidx.core.view.GestureDetectorCompat;
14
15
  import androidx.core.view.MotionEventCompat;
@@ -46,6 +47,7 @@ import com.google.android.gms.maps.model.CameraPosition;
46
47
  import com.google.android.gms.maps.model.GroundOverlay;
47
48
  import com.google.android.gms.maps.model.LatLng;
48
49
  import com.google.android.gms.maps.model.LatLngBounds;
50
+ import com.google.android.gms.maps.model.MapStyleOptions;
49
51
  import com.google.android.gms.maps.model.Marker;
50
52
  import com.google.android.gms.maps.model.MarkerOptions;
51
53
  import com.google.android.gms.maps.model.PointOfInterest;
@@ -92,6 +94,8 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
92
94
  private boolean moveOnMarkerPress = true;
93
95
  private boolean cacheEnabled = false;
94
96
  private ReadableMap initialRegion;
97
+ private ReadableMap region;
98
+ private String customMapStyleString;
95
99
  private boolean initialRegionSet = false;
96
100
  private boolean initialCameraSet = false;
97
101
  private LatLngBounds cameraLastIdleBounds;
@@ -219,10 +223,8 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
219
223
  this.map.setOnMarkerDragListener(this);
220
224
  this.map.setOnPoiClickListener(this);
221
225
  this.map.setOnIndoorStateChangeListener(this);
222
- if(initialRegion != null) {
223
- setRegion(initialRegion);
224
- initialRegionSet = true;
225
- }
226
+
227
+ applyBridgedProps();
226
228
 
227
229
  manager.pushEvent(context, this, "onMapReady", new WritableNativeMap());
228
230
 
@@ -465,9 +467,9 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
465
467
  public void setInitialRegion(ReadableMap initialRegion) {
466
468
  this.initialRegion = initialRegion;
467
469
  // Theoretically onMapReady might be called before setInitialRegion
468
- // In that case, trigger setRegion manually
470
+ // In that case, trigger moveToRegion manually
469
471
  if (!initialRegionSet && map != null) {
470
- setRegion(initialRegion);
472
+ moveToRegion(initialRegion);
471
473
  initialRegionSet = true;
472
474
  }
473
475
  }
@@ -479,16 +481,28 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
479
481
  }
480
482
  }
481
483
 
482
- public void setRegion(ReadableMap region) {
484
+ private void applyBridgedProps() {
485
+ if(initialRegion != null) {
486
+ moveToRegion(initialRegion);
487
+ initialRegionSet = true;
488
+ } else {
489
+ moveToRegion(region);
490
+ }
491
+ if(customMapStyleString != null) {
492
+ map.setMapStyle(new MapStyleOptions(customMapStyleString));
493
+ }
494
+ }
495
+
496
+ private void moveToRegion(ReadableMap region) {
483
497
  if (region == null) return;
484
498
 
485
- Double lng = region.getDouble("longitude");
486
- Double lat = region.getDouble("latitude");
487
- Double lngDelta = region.getDouble("longitudeDelta");
488
- Double latDelta = region.getDouble("latitudeDelta");
499
+ double lng = region.getDouble("longitude");
500
+ double lat = region.getDouble("latitude");
501
+ double lngDelta = region.getDouble("longitudeDelta");
502
+ double latDelta = region.getDouble("latitudeDelta");
489
503
  LatLngBounds bounds = new LatLngBounds(
490
- new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
491
- new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
504
+ new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
505
+ new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
492
506
  );
493
507
  if (super.getHeight() <= 0 || super.getWidth() <= 0) {
494
508
  // in this case, our map has not been laid out yet, so we save the bounds in a local
@@ -503,6 +517,13 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
503
517
  }
504
518
  }
505
519
 
520
+ public void setRegion(ReadableMap region) {
521
+ this.region = region;
522
+ if(region != null && map != null) {
523
+ moveToRegion(region);
524
+ }
525
+ }
526
+
506
527
  public void setCamera(ReadableMap camera) {
507
528
  if (camera == null) return;
508
529
 
@@ -532,6 +553,13 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
532
553
  }
533
554
  }
534
555
 
556
+ public void setMapStyle(@Nullable String customMapStyleString) {
557
+ this.customMapStyleString = customMapStyleString;
558
+ if(map != null && customMapStyleString != null) {
559
+ map.setMapStyle(new MapStyleOptions(customMapStyleString));
560
+ }
561
+ }
562
+
535
563
  public void setShowsUserLocation(boolean showUserLocation) {
536
564
  this.showUserLocation = showUserLocation; // hold onto this for lifecycle handling
537
565
  if (hasPermissions()) {
@@ -1,5 +1,6 @@
1
1
  package com.airbnb.android.react.maps;
2
2
 
3
+ import android.annotation.SuppressLint;
3
4
  import android.content.Context;
4
5
  import android.location.Location;
5
6
  import android.os.Looper;
@@ -9,6 +10,7 @@ import com.google.android.gms.location.LocationCallback;
9
10
  import com.google.android.gms.location.LocationRequest;
10
11
  import com.google.android.gms.location.LocationResult;
11
12
  import com.google.android.gms.location.LocationServices;
13
+ import com.google.android.gms.location.Priority;
12
14
  import com.google.android.gms.maps.LocationSource;
13
15
  import com.google.android.gms.tasks.OnSuccessListener;
14
16
 
@@ -24,7 +26,7 @@ public class FusedLocationSource implements LocationSource {
24
26
  fusedLocationClientProviderClient =
25
27
  LocationServices.getFusedLocationProviderClient(context);
26
28
  locationRequest = LocationRequest.create();
27
- locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
29
+ locationRequest.setPriority(Priority.PRIORITY_HIGH_ACCURACY);
28
30
  locationRequest.setInterval(5000);
29
31
  }
30
32
 
@@ -40,6 +42,7 @@ public class FusedLocationSource implements LocationSource {
40
42
  locationRequest.setFastestInterval(fastestInterval);
41
43
  }
42
44
 
45
+ @SuppressLint("MissingPermission")
43
46
  @Override
44
47
  public void activate(final OnLocationChangedListener onLocationChangedListener) {
45
48
  try {
package/lib/MapView.d.ts CHANGED
@@ -568,20 +568,12 @@ declare type NativeProps = Omit<ModifiedProps, 'customMapStyle' | 'onRegionChang
568
568
  declare type State = {
569
569
  isReady: boolean;
570
570
  };
571
- declare type SnapShot = Region | null;
572
- declare class MapView extends React.Component<MapViewProps, State, SnapShot> {
571
+ declare class MapView extends React.Component<MapViewProps, State> {
573
572
  static Animated: Animated.AnimatedComponent<typeof MapView>;
574
573
  private map;
575
- private __lastRegion;
576
- private __layoutCalled;
577
574
  constructor(props: MapViewProps);
578
575
  setNativeProps(props: Partial<NativeProps>): void;
579
- getSnapshotBeforeUpdate(prevProps: MapViewProps): Region | null;
580
- componentDidUpdate(_prevProps: MapViewProps, _prevState: State, region: SnapShot): void;
581
- componentDidMount(): void;
582
- private _updateStyle;
583
576
  private _onMapReady;
584
- private _onLayout;
585
577
  private _onChange;
586
578
  getCamera(): Promise<Camera>;
587
579
  setCamera(camera: Partial<Camera>): void;
package/lib/MapView.js CHANGED
@@ -40,8 +40,6 @@ const GOOGLE_MAPS_ONLY_TYPES = [exports.MAP_TYPES.TERRAIN, exports.MAP_TYPES.NON
40
40
  class MapView extends React.Component {
41
41
  static Animated;
42
42
  map;
43
- __lastRegion;
44
- __layoutCalled;
45
43
  constructor(props) {
46
44
  super(props);
47
45
  this.map = React.createRef();
@@ -50,79 +48,19 @@ class MapView extends React.Component {
50
48
  };
51
49
  this._onMapReady = this._onMapReady.bind(this);
52
50
  this._onChange = this._onChange.bind(this);
53
- this._onLayout = this._onLayout.bind(this);
54
51
  }
55
52
  setNativeProps(props) {
56
53
  this.map.current?.setNativeProps(props);
57
54
  }
58
- getSnapshotBeforeUpdate(prevProps) {
59
- if (this.state.isReady &&
60
- this.props.customMapStyle !== prevProps.customMapStyle) {
61
- this._updateStyle(this.props.customMapStyle);
62
- }
63
- return this.props.region || null;
64
- }
65
- componentDidUpdate(_prevProps, _prevState, region) {
66
- const a = this.__lastRegion;
67
- const b = region;
68
- if (!a || !b) {
69
- return;
70
- }
71
- if (a.latitude !== b.latitude ||
72
- a.longitude !== b.longitude ||
73
- a.latitudeDelta !== b.latitudeDelta ||
74
- a.longitudeDelta !== b.longitudeDelta) {
75
- this.map.current?.setNativeProps({ region: b });
76
- }
77
- }
78
- componentDidMount() {
79
- const { isReady } = this.state;
80
- if (isReady) {
81
- this._updateStyle(this.props.customMapStyle);
82
- }
83
- }
84
- _updateStyle(customMapStyle) {
85
- this.map.current?.setNativeProps({
86
- customMapStyleString: JSON.stringify(customMapStyle),
87
- });
88
- }
89
55
  _onMapReady() {
90
- const { region, initialRegion, onMapReady } = this.props;
91
- if (region) {
92
- this.map.current?.setNativeProps({ region });
93
- }
94
- else if (initialRegion) {
95
- this.map.current?.setNativeProps({ initialRegion });
96
- }
97
- this._updateStyle(this.props.customMapStyle);
56
+ const { onMapReady } = this.props;
98
57
  this.setState({ isReady: true }, () => {
99
58
  if (onMapReady) {
100
59
  onMapReady();
101
60
  }
102
61
  });
103
62
  }
104
- _onLayout(e) {
105
- const { layout } = e.nativeEvent;
106
- if (!layout.width || !layout.height) {
107
- return;
108
- }
109
- if (this.state.isReady && !this.__layoutCalled) {
110
- const { region, initialRegion } = this.props;
111
- if (region) {
112
- this.__layoutCalled = true;
113
- this.map.current?.setNativeProps({ region });
114
- }
115
- else if (initialRegion) {
116
- this.__layoutCalled = true;
117
- this.map.current?.setNativeProps({ initialRegion });
118
- }
119
- }
120
- if (this.props.onLayout) {
121
- this.props.onLayout(e);
122
- }
123
- }
124
63
  _onChange({ nativeEvent }) {
125
- this.__lastRegion = nativeEvent.region;
126
64
  const isGesture = nativeEvent.isGesture;
127
65
  const details = { isGesture };
128
66
  if (nativeEvent.continuous) {
@@ -354,8 +292,10 @@ class MapView extends React.Component {
354
292
  initialRegion: null,
355
293
  onChange: this._onChange,
356
294
  onMapReady: this._onMapReady,
357
- onLayout: this._onLayout,
358
295
  ref: this.map,
296
+ customMapStyleString: this.props.customMapStyle
297
+ ? JSON.stringify(this.props.customMapStyle)
298
+ : undefined,
359
299
  ...this.props,
360
300
  };
361
301
  if (react_native_1.Platform.OS === 'ios' &&
@@ -376,7 +316,9 @@ class MapView extends React.Component {
376
316
  ref: this.map,
377
317
  onChange: this._onChange,
378
318
  onMapReady: this._onMapReady,
379
- onLayout: this._onLayout,
319
+ customMapStyleString: this.props.customMapStyle
320
+ ? JSON.stringify(this.props.customMapStyle)
321
+ : undefined,
380
322
  };
381
323
  }
382
324
  if (react_native_1.Platform.OS === 'android' && this.props.liteMode) {
package/package.json CHANGED
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "react-native-maps",
3
3
  "description": "React Native Mapview component for iOS + Android",
4
+ "source": "src/index",
4
5
  "main": "lib/index.js",
5
6
  "author": "Leland Richardson <leland.m.richardson@gmail.com>",
6
- "version": "1.0.0-beta.9",
7
+ "homepage": "https://github.com/react-native-maps/react-native-maps#readme",
8
+ "version": "1.1.0-beta.2",
7
9
  "license": "MIT",
8
10
  "scripts": {
9
11
  "lint": "eslint . --max-warnings 0",
10
12
  "tscheck": "tsc --noEmit",
11
- "build": "tsc",
13
+ "build": "tsc --project tsconfig.build.json",
12
14
  "test": "jest",
13
15
  "prepare": "husky install",
14
- "release": "semantic-release"
16
+ "release": "semantic-release",
17
+ "bootstrap": "yarn --cwd example && yarn && (cd example && cd ios && pod install)"
15
18
  },
16
19
  "files": [
17
20
  "lib",
@@ -49,17 +52,17 @@
49
52
  }
50
53
  },
51
54
  "devDependencies": {
52
- "@commitlint/cli": "17.0.2",
53
- "@commitlint/config-conventional": "17.0.2",
54
- "@react-native-community/eslint-config": "^3.0.2",
55
- "@types/react-native": "0.68.0",
55
+ "@commitlint/cli": "17.0.3",
56
+ "@commitlint/config-conventional": "17.0.3",
57
+ "@react-native-community/eslint-config": "3.0.3",
58
+ "@types/react-native": "0.69.2",
56
59
  "babel-jest": "^27.3.1",
57
- "eslint": "7.32.0",
60
+ "eslint": "^7.32.0",
58
61
  "husky": "8.0.1",
59
62
  "jest": "^27.3.1",
60
63
  "prettier": "2.7.1",
61
- "react": "17.0.2",
62
- "react-native": "0.68.2",
64
+ "react": "18.0.0",
65
+ "react-native": "0.69.1",
63
66
  "semantic-release": "19.0.3",
64
67
  "typescript": "4.7.4"
65
68
  },
@@ -5,11 +5,10 @@ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
5
5
  Pod::Spec.new do |s|
6
6
  s.name = "react-native-google-maps"
7
7
  s.version = package['version']
8
- s.summary = "React Native Mapview component for iOS + Android"
9
-
10
- s.authors = { "intelligibabble" => "leland.m.richardson@gmail.com" }
11
- s.homepage = "https://github.com/react-native-maps/react-native-maps#readme"
12
- s.license = "MIT"
8
+ s.summary = package["description"]
9
+ s.authors = package["author"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
13
12
  s.platform = :ios, "13.0"
14
13
 
15
14
  s.source = { :git => "https://github.com/react-native-maps/react-native-maps.git", :tag=> "v#{s.version}" }
@@ -5,11 +5,10 @@ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
5
5
  Pod::Spec.new do |s|
6
6
  s.name = "react-native-maps"
7
7
  s.version = package['version']
8
- s.summary = "React Native Mapview component for iOS + Android"
9
-
10
- s.authors = { "intelligibabble" => "leland.m.richardson@gmail.com" }
11
- s.homepage = "https://github.com/react-native-maps/react-native-maps#readme"
12
- s.license = "MIT"
8
+ s.summary = package["description"]
9
+ s.authors = package["author"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
13
12
  s.platform = :ios, "11.0"
14
13
 
15
14
  s.source = { :git => "https://github.com/react-native-maps/react-native-maps.git", :tag=> "v#{s.version}" }