react-native-maps 1.21.0-alpha.60 → 1.21.0-alpha.62

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.
@@ -101,9 +101,9 @@ repositories {
101
101
 
102
102
  dependencies {
103
103
  implementation 'com.facebook.react:react-native:+'
104
- implementation "com.google.android.gms:play-services-base:${safeExtGet('playServicesVersion', '18.2.0')}"
105
- implementation "com.google.android.gms:play-services-maps:${safeExtGet('playServicesVersion', '18.2.0')}"
104
+ implementation "com.google.android.gms:play-services-base:${safeExtGet('playServicesVersion', '18.5.0')}"
105
+ implementation "com.google.android.gms:play-services-maps:${safeExtGet('playServicesVersion', '18.5.0')}"
106
106
  implementation "com.google.android.gms:play-services-location:21.0.1"
107
- implementation 'com.google.maps.android:android-maps-utils:3.8.2'
107
+ implementation 'com.google.maps.android:android-maps-utils:3.10.0'
108
108
  implementation "androidx.work:work-runtime:2.7.1"
109
109
  }
@@ -1,5 +1,5 @@
1
1
  distributionBase=GRADLE_USER_HOME
2
2
  distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
@@ -3,6 +3,8 @@ package com.rnmaps.fabric;
3
3
 
4
4
  import static com.rnmaps.maps.MapManager.MY_LOCATION_PRIORITY;
5
5
 
6
+ import android.graphics.drawable.Drawable;
7
+ import android.net.Uri;
6
8
  import android.util.Log;
7
9
  import android.view.View;
8
10
 
@@ -13,7 +15,6 @@ import org.json.JSONArray;
13
15
  import org.json.JSONException;
14
16
  import org.json.JSONObject;
15
17
 
16
- import com.facebook.react.bridge.Arguments;
17
18
  import com.facebook.react.bridge.ReactApplicationContext;
18
19
  import com.facebook.react.bridge.ReadableMap;
19
20
  import com.facebook.react.bridge.WritableArray;
@@ -23,17 +24,19 @@ import com.facebook.react.uimanager.LayoutShadowNode;
23
24
  import com.facebook.react.uimanager.ReactStylesDiffMap;
24
25
  import com.facebook.react.uimanager.StateWrapper;
25
26
  import com.facebook.react.uimanager.ThemedReactContext;
26
- import com.facebook.react.uimanager.UIManagerHelper;
27
27
  import com.facebook.react.uimanager.ViewGroupManager;
28
28
  import com.facebook.react.uimanager.ViewManagerDelegate;
29
29
  import com.facebook.react.viewmanagers.RNMapsMapViewManagerInterface;
30
30
  import com.facebook.react.viewmanagers.RNMapsMapViewManagerDelegate;
31
+ import com.google.android.gms.common.images.ImageManager;
31
32
  import com.google.android.gms.maps.GoogleMap;
32
33
  import com.google.android.gms.maps.GoogleMapOptions;
33
34
  import com.google.android.gms.maps.MapsInitializer;
34
35
  import com.google.android.gms.maps.model.CameraPosition;
35
36
  import com.google.android.gms.maps.model.LatLng;
36
37
  import com.google.android.gms.maps.model.LatLngBounds;
38
+ import com.google.android.gms.maps.model.MapColorScheme;
39
+ import com.rnmaps.maps.MapMarker;
37
40
  import com.rnmaps.maps.MapView;
38
41
  import com.rnmaps.maps.SizeReportingShadowNode;
39
42
 
@@ -105,6 +108,16 @@ public class MapViewManager extends ViewGroupManager<MapView> implements RNMapsM
105
108
  options.maxZoomPreference(initialProps.getInt("maxZoom", 0));
106
109
  }
107
110
  }
111
+ if (initialProps.hasKey("userInterfaceStyle")){
112
+ String style = initialProps.getString("userInterfaceStyle");
113
+ if ("system".equals(style)) {
114
+ options.mapColorScheme(MapColorScheme.FOLLOW_SYSTEM);
115
+ } else if ("light".equals(style)){
116
+ options.mapColorScheme(MapColorScheme.LIGHT);
117
+ } else if ("dark".equals(style)){
118
+ options.mapColorScheme(MapColorScheme.DARK);
119
+ }
120
+ }
108
121
  if (initialProps.hasKey("pitchEnabled")) {
109
122
  options.tiltGesturesEnabled(initialProps.getBoolean("pitchEnabled", true));
110
123
  }
@@ -292,7 +305,13 @@ public class MapViewManager extends ViewGroupManager<MapView> implements RNMapsM
292
305
 
293
306
  @Override
294
307
  public void addView(MapView parent, View child, int index) {
295
- parent.addFeature(child, index);
308
+ if (child instanceof MapMarker && ((MapMarker) child).isLoadingImage()){
309
+ ((MapMarker) child).setImageLoadedListener((uri, drawable, b) -> {
310
+ parent.addFeature(child, parent.getFeatureCount());
311
+ });
312
+ } else {
313
+ parent.addFeature(child, index);
314
+ }
296
315
  }
297
316
 
298
317
  @Override
@@ -426,7 +445,7 @@ public class MapViewManager extends ViewGroupManager<MapView> implements RNMapsM
426
445
 
427
446
  @Override
428
447
  public void setUserInterfaceStyle(MapView view, @Nullable String value) {
429
- // todo update google maps SDK and add support for MapColorScheme
448
+ // do nothing (initialProp)
430
449
  }
431
450
 
432
451
  @Override
@@ -1,23 +1,24 @@
1
1
  package com.rnmaps.fabric;
2
2
 
3
3
 
4
+ import android.util.Log;
5
+
6
+ import androidx.annotation.NonNull;
4
7
  import androidx.annotation.Nullable;
5
8
 
6
9
  import com.facebook.react.bridge.ReactApplicationContext;
7
10
  import com.facebook.react.bridge.ReadableMap;
8
11
  import com.facebook.react.module.annotations.ReactModule;
12
+ import com.facebook.react.uimanager.ReactStylesDiffMap;
13
+ import com.facebook.react.uimanager.StateWrapper;
9
14
  import com.facebook.react.uimanager.ThemedReactContext;
10
15
  import com.facebook.react.uimanager.ViewGroupManager;
11
16
  import com.facebook.react.uimanager.ViewManagerDelegate;
12
- import com.facebook.react.viewmanagers.RNMapsMapViewManagerDelegate;
13
- import com.facebook.react.viewmanagers.RNMapsMapViewManagerInterface;
14
17
  import com.facebook.react.viewmanagers.RNMapsMarkerManagerDelegate;
15
18
  import com.facebook.react.viewmanagers.RNMapsMarkerManagerInterface;
16
- import com.google.android.gms.maps.GoogleMap;
17
- import com.google.android.gms.maps.GoogleMapOptions;
18
19
  import com.google.android.gms.maps.model.LatLng;
20
+ import com.google.android.gms.maps.model.MarkerOptions;
19
21
  import com.rnmaps.maps.MapMarker;
20
- import com.rnmaps.maps.MapView;
21
22
 
22
23
  import java.util.Map;
23
24
 
@@ -28,7 +29,6 @@ public class MarkerManager extends ViewGroupManager<MapMarker> implements RNMaps
28
29
  public MarkerManager(ReactApplicationContext context){
29
30
  super(context);
30
31
  }
31
- private GoogleMapOptions options;
32
32
  private final RNMapsMarkerManagerDelegate<MapMarker, MarkerManager> delegate =
33
33
  new RNMapsMarkerManagerDelegate<>(this);
34
34
 
@@ -46,6 +46,70 @@ public class MarkerManager extends ViewGroupManager<MapMarker> implements RNMaps
46
46
  public MapMarker createViewInstance(ThemedReactContext context) {
47
47
  return new MapMarker(context, null);
48
48
  }
49
+ private MarkerOptions optionsForInitialProps(ReactStylesDiffMap initialProps){
50
+ MarkerOptions options = new MarkerOptions();
51
+ if (initialProps != null) {
52
+ if (initialProps.hasKey("opacity")) {
53
+ options.alpha(initialProps.getFloat("opacity", 1));
54
+ }
55
+ if (initialProps.hasKey("anchor")) {
56
+ ReadableMap map = initialProps.getMap("anchor");
57
+ float x = (float) (map != null && map.hasKey("x") ? map.getDouble("x") : 0.5);
58
+ float y = (float) (map != null && map.hasKey("y") ? map.getDouble("y") : 1.0);
59
+ options.anchor(x, y);
60
+ }
61
+
62
+ if (initialProps.hasKey("coordinate")) {
63
+ ReadableMap coordinate = initialProps.getMap("coordinate");
64
+ LatLng position = new LatLng(coordinate.getDouble("latitude"), coordinate.getDouble("longitude"));
65
+ options.position(position);
66
+ }
67
+ if (initialProps.hasKey("title")) {
68
+ options.title(initialProps.getString("title"));
69
+ }
70
+ if (initialProps.hasKey("description")) {
71
+ options.snippet(initialProps.getString("description"));
72
+ }
73
+ if (initialProps.hasKey("draggable")){
74
+ options.draggable(initialProps.getBoolean("draggable", false));
75
+ }
76
+ if (initialProps.hasKey("rotation")){
77
+ options.rotation(initialProps.getFloat("rotation", 0));
78
+ }
79
+ if (initialProps.hasKey("flat")) {
80
+ options.flat(initialProps.getBoolean("flat", false));
81
+ }
82
+ if (initialProps.hasKey("calloutAnchor")){
83
+ ReadableMap map = initialProps.getMap("calloutAnchor");
84
+ float x = (float) (map != null && map.hasKey("x") ? map.getDouble("x") : 0.5);
85
+ float y = (float) (map != null && map.hasKey("y") ? map.getDouble("y") : 1.0);
86
+ options.infoWindowAnchor(x, y);
87
+ }
88
+
89
+ if (initialProps.hasKey("zIndex")){
90
+ options.zIndex(initialProps.getFloat("zIndex", 0));
91
+ }
92
+ }
93
+ return options;
94
+ }
95
+
96
+ @Override
97
+ protected MapMarker createViewInstance(int reactTag, @NonNull ThemedReactContext reactContext, @Nullable ReactStylesDiffMap initialProps, @Nullable StateWrapper stateWrapper) {
98
+ MapMarker view = null;
99
+ view = new MapMarker(reactContext, optionsForInitialProps(initialProps), null);
100
+ view.setId(reactTag);
101
+ this.addEventEmitters(reactContext, view);
102
+ if (initialProps != null) {
103
+ this.updateProperties(view, initialProps);
104
+ }
105
+ if (stateWrapper != null) {
106
+ Object extraData = this.updateState(view, initialProps, stateWrapper);
107
+ if (extraData != null) {
108
+ this.updateExtraData(view, extraData);
109
+ }
110
+ }
111
+ return view;
112
+ }
49
113
 
50
114
 
51
115
  public static final String REACT_CLASS = "RNMapsMarker";
@@ -76,7 +140,7 @@ public class MarkerManager extends ViewGroupManager<MapMarker> implements RNMaps
76
140
 
77
141
  @Override
78
142
  public void setImage(MapMarker view, @Nullable ReadableMap value) {
79
-
143
+ view.setImage(value.getString("uri"));
80
144
  }
81
145
 
82
146
  @Override
@@ -39,6 +39,7 @@ import com.facebook.react.common.MapBuilder;
39
39
  import com.facebook.react.uimanager.UIManagerHelper;
40
40
  import com.facebook.react.uimanager.events.Event;
41
41
  import com.facebook.react.uimanager.events.EventDispatcher;
42
+ import com.google.android.gms.common.images.ImageManager;
42
43
  import com.google.android.gms.maps.model.BitmapDescriptor;
43
44
  import com.google.android.gms.maps.model.BitmapDescriptorFactory;
44
45
  import com.google.android.gms.maps.model.LatLng;
@@ -94,11 +95,17 @@ public class MapMarker extends MapFeature {
94
95
  private boolean hasCustomMarkerView = false;
95
96
  private final MapMarkerManager markerManager;
96
97
  private String imageUri;
98
+ private boolean loadingImage;
97
99
 
98
100
  private final DraweeHolder<?> logoHolder;
101
+ private ImageManager.OnImageLoadedListener imageLoadedListener;
99
102
  private DataSource<CloseableReference<CloseableImage>> dataSource;
100
103
  private final ControllerListener<ImageInfo> mLogoControllerListener =
101
104
  new BaseControllerListener<ImageInfo>() {
105
+ @Override
106
+ public void onSubmit(String id, Object callerContext){
107
+ loadingImage = true;
108
+ }
102
109
  @Override
103
110
  public void onFinalImageSet(
104
111
  String id,
@@ -130,6 +137,12 @@ public class MapMarker extends MapFeature {
130
137
  .updateIcon(iconBitmapDescriptor, iconBitmap);
131
138
  }
132
139
  update(true);
140
+ loadingImage = false;
141
+ if (imageLoadedListener != null){
142
+ imageLoadedListener.onImageLoaded(null, null, false);
143
+ // fire and forget
144
+ imageLoadedListener = null;
145
+ }
133
146
  }
134
147
  };
135
148
 
@@ -157,7 +170,7 @@ public class MapMarker extends MapFeature {
157
170
  setFlat(options.isFlat());
158
171
  setDraggable(options.isDraggable());
159
172
  setZIndex(Math.round(options.getZIndex()));
160
- setAlpha(options.getAlpha());
173
+ setOpacity(options.getAlpha());
161
174
  iconBitmapDescriptor = options.getIcon();
162
175
  }
163
176
 
@@ -438,7 +451,6 @@ public class MapMarker extends MapFeature {
438
451
  updateTracksViewChanges();
439
452
  update(true);
440
453
  }
441
-
442
454
  }
443
455
  }
444
456
 
@@ -635,11 +647,23 @@ public class MapMarker extends MapFeature {
635
647
  getContext().getPackageName());
636
648
  }
637
649
 
638
- @FunctionalInterface
650
+ public boolean isLoadingImage() {
651
+ return loadingImage;
652
+ }
653
+
654
+ public ImageManager.OnImageLoadedListener getImageLoadedListener() {
655
+ return imageLoadedListener;
656
+ }
657
+
658
+ public void setImageLoadedListener(ImageManager.OnImageLoadedListener imageLoadedListener) {
659
+ this.imageLoadedListener = imageLoadedListener;
660
+ }
661
+
662
+ @FunctionalInterface
639
663
  public interface EventCreator<T extends Event> {
640
664
  T create(int surfaceId, int viewId, WritableMap payload);
641
665
  }
642
- private <T extends Event> void dispatchEvent(WritableMap payload, MapView.EventCreator<T> creator) {
666
+ public <T extends Event> void dispatchEvent(WritableMap payload, MapView.EventCreator<T> creator) {
643
667
  // Cast context to ReactContext
644
668
  ReactContext reactContext = (ReactContext) context;
645
669
 
@@ -356,17 +356,15 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
356
356
  MapMarker airMapMarker = getMarkerMap(marker);
357
357
 
358
358
  WritableMap eventData = makeClickEventData(marker.getPosition());
359
- eventData.putString("action", "marker-press");
359
+ eventData.putString("action", "press");
360
360
  eventData.putString("id", airMapMarker.getIdentifier());
361
+ airMapMarker.dispatchEvent(eventData, OnPressEvent::new);
361
362
 
362
- dispatchEvent(eventData, OnMarkerPressEvent::new);
363
+ WritableMap mapEventData = makeClickEventData(marker.getPosition());
364
+ mapEventData.putString("action", "marker-press");
365
+ mapEventData.putString("id", airMapMarker.getIdentifier());
363
366
 
364
-
365
- eventData = makeClickEventData(marker.getPosition());
366
- eventData.putString("action", "marker-press");
367
- eventData.putString("id", airMapMarker.getIdentifier());
368
-
369
- dispatchEvent(eventData, OnPressEvent::new);
367
+ dispatchEvent(mapEventData, OnMarkerPressEvent::new);
370
368
 
371
369
 
372
370
  handleMarkerSelection(airMapMarker);
@@ -564,8 +562,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
564
562
  event = makeClickEventData(selectedMarker.getPosition());
565
563
  event.putString("action", "marker-deselect");
566
564
  event.putString("id", selectedMarker.getIdentifier());
567
- // todo: use Fabric events
568
- // manager.pushEvent(context, selectedMarker, "onDeselect", event);
565
+ selectedMarker.dispatchEvent(event, OnDeselectEvent::new);
569
566
 
570
567
  event = makeClickEventData(selectedMarker.getPosition());
571
568
  event.putString("action", "marker-deselect");
@@ -577,8 +574,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
577
574
  event = makeClickEventData(target.getPosition());
578
575
  event.putString("action", "marker-select");
579
576
  event.putString("id", target.getIdentifier());
580
- // todo: use Fabric events
581
- // manager.pushEvent(context, target, "onSelect", event);
577
+ target.dispatchEvent(event, OnSelectEvent::new);
582
578
 
583
579
  event = makeClickEventData(target.getPosition());
584
580
  event.putString("action", "marker-select");
package/lib/MapView.d.ts CHANGED
@@ -493,7 +493,7 @@ export type MapViewProps = ViewProps & {
493
493
  *
494
494
  * @default System setting
495
495
  * @platform iOS: Apple Maps only (iOS >= 13.0)
496
- * @platform Android: Not supported
496
+ * @platform Android: Supported
497
497
  */
498
498
  userInterfaceStyle?: 'light' | 'dark';
499
499
  /**
@@ -167,7 +167,7 @@ export interface MarkerFabricNativeProps extends ViewProps {
167
167
  * Callback that is called when the marker is deselected, before the callout is hidden.
168
168
  *
169
169
  * @platform iOS: Apple Maps only
170
- * @platform Android: Not supported
170
+ * @platform Android: supported
171
171
  */
172
172
  onDeselect?: MarkerPressEventHandler;
173
173
  /**
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.21.0-alpha.60",
8
+ "version": "1.21.0-alpha.62",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",