react-native-maps 1.24.1 → 1.24.3

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.
package/README.md CHANGED
@@ -19,7 +19,7 @@ See [Setup Instructions for the Included Example Project](docs/examples-setup.md
19
19
  ### Important Notes:
20
20
 
21
21
  - **Fabric is now supported**:
22
- Fabric is now supported for the latest version of the library, if you don't have Fabric (New Arch) enabled, please use v1.21.0 or earlier
22
+ Fabric is now supported for the latest version of the library, **latest version is strongly recommended** because many regressions appeared after the release of v1.22.0 if you don't have Fabric (New Arch) enabled, please use v1.21.0 or earlier
23
23
 
24
24
  ### Version Requirements:
25
25
 
@@ -132,6 +132,9 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
132
132
  private int cameraMoveReason = 0;
133
133
  private MapMarker selectedMarker;
134
134
 
135
+ private LifecycleOwner currentLifecycleOwner;
136
+ private boolean isLifecycleObserverAttached = false;
137
+
135
138
  private static final String[] PERMISSIONS = new String[]{
136
139
  "android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"};
137
140
 
@@ -250,10 +253,6 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
250
253
  GoogleMapOptions googleMapOptions) {
251
254
  super(context, googleMapOptions);
252
255
  this.context = context;
253
- Activity activity = context.getCurrentActivity();
254
- if (activity instanceof LifecycleOwner) {
255
- ((LifecycleOwner) activity).getLifecycle().addObserver(this);
256
- }
257
256
  super.getMapAsync(this);
258
257
 
259
258
  final MapView view = this;
@@ -309,6 +308,38 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
309
308
 
310
309
  }
311
310
 
311
+ @Override
312
+ protected void onAttachedToWindow() {
313
+ super.onAttachedToWindow();
314
+ attachLifecycleObserver();
315
+ }
316
+
317
+ // Override onDetachedFromWindow to detach lifecycle observer
318
+ @Override
319
+ protected void onDetachedFromWindow() {
320
+ detachLifecycleObserver();
321
+ super.onDetachedFromWindow();
322
+ }
323
+
324
+ // Method to attach lifecycle observer
325
+ private void attachLifecycleObserver() {
326
+ Activity activity = context.getCurrentActivity();
327
+ if (activity instanceof LifecycleOwner && !isLifecycleObserverAttached) {
328
+ currentLifecycleOwner = (LifecycleOwner) activity;
329
+ currentLifecycleOwner.getLifecycle().addObserver(this);
330
+ isLifecycleObserverAttached = true;
331
+ }
332
+ }
333
+
334
+ // Method to detach lifecycle observer
335
+ private void detachLifecycleObserver() {
336
+ if (currentLifecycleOwner != null && isLifecycleObserverAttached) {
337
+ currentLifecycleOwner.getLifecycle().removeObserver(this);
338
+ isLifecycleObserverAttached = false;
339
+ currentLifecycleOwner = null;
340
+ }
341
+ }
342
+
312
343
  public double[][] getMarkersFrames(boolean onlyVisible) {
313
344
 
314
345
  LatLngBounds.Builder builder = new LatLngBounds.Builder();
@@ -689,10 +720,9 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
689
720
  }
690
721
  destroyed = true;
691
722
 
692
- Activity activity = context.getCurrentActivity();
693
- if (activity instanceof LifecycleOwner) {
694
- ((LifecycleOwner) activity).getLifecycle().removeObserver(this);
695
- }
723
+ // Detach lifecycle observer before destroying
724
+ detachLifecycleObserver();
725
+
696
726
  if (!paused) {
697
727
  onPause();
698
728
  paused = true;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "main": "src/index.ts",
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.24.1",
8
+ "version": "1.24.3",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",
package/src/MapMarker.tsx CHANGED
@@ -481,13 +481,29 @@ export class MapMarker extends React.Component<MapMarkerProps> {
481
481
  );
482
482
  }
483
483
 
484
- let icon;
485
- if (this.props.icon && this.fabricMarker) {
486
- icon = fixImageProp(this.props.icon);
487
- }
488
- let image;
489
- if (this.props.image && this.fabricMarker) {
490
- image = fixImageProp(this.props.image);
484
+ let icon: any = this.props.icon;
485
+ let image: any = this.props.image;
486
+
487
+ if (this.fabricMarker) {
488
+ if (this.props.image) {
489
+ image = fixImageProp(this.props.image);
490
+ }
491
+ if (this.props.icon) {
492
+ icon = fixImageProp(this.props.icon);
493
+ }
494
+ } else {
495
+ if (this.props.image) {
496
+ image = fixImageProp(this.props.image);
497
+ if (image.uri) {
498
+ image = image.uri;
499
+ }
500
+ }
501
+ if (this.props.icon) {
502
+ icon = fixImageProp(this.props.icon);
503
+ if (icon.uri) {
504
+ icon = icon.uri;
505
+ }
506
+ }
491
507
  }
492
508
 
493
509
  const AIRMapMarker = this.getNativeComponent();
@@ -32,7 +32,7 @@ export type MapOverlayProps = ViewProps & {
32
32
  bearing?: number;
33
33
 
34
34
  /**
35
- * The coordinates for the image (left-top corner, right-bottom corner). ie.```[[lat, long], [lat, long]]```
35
+ * The coordinates for the image (right-top corner, left-bottom corner). ie.```[[lat, long], [lat, long]]```
36
36
  *
37
37
  * @platform iOS: Supported
38
38
  * @platform Android: Supported