react-native-maps 1.21.0-alpha.61 → 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.
- package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +11 -1
- package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +71 -7
- package/android/src/main/java/com/rnmaps/maps/MapMarker.java +28 -4
- package/android/src/main/java/com/rnmaps/maps/MapView.java +8 -12
- package/lib/specs/NativeComponentMarker.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
|
@@ -26,6 +28,7 @@ import com.facebook.react.uimanager.ViewGroupManager;
|
|
|
26
28
|
import com.facebook.react.uimanager.ViewManagerDelegate;
|
|
27
29
|
import com.facebook.react.viewmanagers.RNMapsMapViewManagerInterface;
|
|
28
30
|
import com.facebook.react.viewmanagers.RNMapsMapViewManagerDelegate;
|
|
31
|
+
import com.google.android.gms.common.images.ImageManager;
|
|
29
32
|
import com.google.android.gms.maps.GoogleMap;
|
|
30
33
|
import com.google.android.gms.maps.GoogleMapOptions;
|
|
31
34
|
import com.google.android.gms.maps.MapsInitializer;
|
|
@@ -33,6 +36,7 @@ import com.google.android.gms.maps.model.CameraPosition;
|
|
|
33
36
|
import com.google.android.gms.maps.model.LatLng;
|
|
34
37
|
import com.google.android.gms.maps.model.LatLngBounds;
|
|
35
38
|
import com.google.android.gms.maps.model.MapColorScheme;
|
|
39
|
+
import com.rnmaps.maps.MapMarker;
|
|
36
40
|
import com.rnmaps.maps.MapView;
|
|
37
41
|
import com.rnmaps.maps.SizeReportingShadowNode;
|
|
38
42
|
|
|
@@ -301,7 +305,13 @@ public class MapViewManager extends ViewGroupManager<MapView> implements RNMapsM
|
|
|
301
305
|
|
|
302
306
|
@Override
|
|
303
307
|
public void addView(MapView parent, View child, int index) {
|
|
304
|
-
|
|
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
|
+
}
|
|
305
315
|
}
|
|
306
316
|
|
|
307
317
|
@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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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", "
|
|
359
|
+
eventData.putString("action", "press");
|
|
360
360
|
eventData.putString("id", airMapMarker.getIdentifier());
|
|
361
|
+
airMapMarker.dispatchEvent(eventData, OnPressEvent::new);
|
|
361
362
|
|
|
362
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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");
|
|
@@ -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:
|
|
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.
|
|
8
|
+
"version": "1.21.0-alpha.62",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|