react-native-maps 1.21.0-alpha.67 → 1.21.0-alpha.69
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/CalloutManager.java +0 -12
- package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +7 -3
- package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +21 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeCompleteEvent.java +30 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeStartEvent.java +33 -0
- package/android/src/main/java/com/rnmaps/maps/MapCallout.java +7 -8
- package/android/src/main/java/com/rnmaps/maps/MapView.java +41 -52
- package/lib/MapView.d.ts +2 -0
- package/lib/MapView.js +16 -7
- package/package.json +1 -1
|
@@ -20,7 +20,6 @@ import java.util.Map;
|
|
|
20
20
|
@ReactModule(name = CalloutManager.REACT_CLASS)
|
|
21
21
|
public class CalloutManager extends ViewGroupManager<MapCallout> implements RNMapsCalloutManagerInterface<MapCallout> {
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
public CalloutManager(ReactApplicationContext context){
|
|
25
24
|
super(context);
|
|
26
25
|
}
|
|
@@ -75,15 +74,4 @@ public class CalloutManager extends ViewGroupManager<MapCallout> implements RNMa
|
|
|
75
74
|
return new SizeReportingShadowNode();
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
@Override
|
|
79
|
-
public void updateExtraData(MapCallout view, Object extraData) {
|
|
80
|
-
// This method is called from the shadow node with the width/height of the rendered
|
|
81
|
-
// marker view.
|
|
82
|
-
//noinspection unchecked
|
|
83
|
-
Map<String, Float> data = (Map<String, Float>) extraData;
|
|
84
|
-
float width = data.get("width");
|
|
85
|
-
float height = data.get("height");
|
|
86
|
-
view.width = (int) width;
|
|
87
|
-
view.height = (int) height;
|
|
88
|
-
}
|
|
89
77
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.rnmaps.fabric;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
import android.graphics.Color;
|
|
4
5
|
import android.util.Log;
|
|
5
6
|
import android.view.View;
|
|
6
7
|
|
|
@@ -163,7 +164,7 @@ public class MarkerManager extends ViewGroupManager<MapMarker> implements RNMaps
|
|
|
163
164
|
|
|
164
165
|
@Override
|
|
165
166
|
public void setDescription(MapMarker view, @Nullable String value) {
|
|
166
|
-
|
|
167
|
+
view.setSnippet(value);
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
@Override
|
|
@@ -193,7 +194,10 @@ public class MarkerManager extends ViewGroupManager<MapMarker> implements RNMaps
|
|
|
193
194
|
|
|
194
195
|
@Override
|
|
195
196
|
public void setPinColor(MapMarker view, @Nullable Integer value) {
|
|
196
|
-
|
|
197
|
+
float[] hsv = new float[3];
|
|
198
|
+
Color.colorToHSV(value, hsv);
|
|
199
|
+
// NOTE: android only supports a hue
|
|
200
|
+
view.setMarkerHue(hsv[0]);
|
|
197
201
|
}
|
|
198
202
|
|
|
199
203
|
@Override
|
|
@@ -213,7 +217,7 @@ public class MarkerManager extends ViewGroupManager<MapMarker> implements RNMaps
|
|
|
213
217
|
|
|
214
218
|
@Override
|
|
215
219
|
public void animateToCoordinates(MapMarker view, double latitude, double longitude, int duration) {
|
|
216
|
-
|
|
220
|
+
view.animateToCoodinate(new LatLng(latitude, longitude), duration);
|
|
217
221
|
}
|
|
218
222
|
|
|
219
223
|
@Override
|
|
@@ -20,6 +20,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
|
|
20
20
|
import com.facebook.react.bridge.ReadableMap;
|
|
21
21
|
import com.facebook.react.bridge.UIManager;
|
|
22
22
|
import com.facebook.react.bridge.WritableMap;
|
|
23
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
23
24
|
import com.facebook.react.uimanager.UIManagerHelper;
|
|
24
25
|
import com.google.android.gms.maps.GoogleMap;
|
|
25
26
|
import com.google.android.gms.maps.model.CameraPosition;
|
|
@@ -71,7 +72,27 @@ public class NativeAirMapsModule extends NativeAirMapsModuleSpec {
|
|
|
71
72
|
|
|
72
73
|
@Override
|
|
73
74
|
public void getMapBoundaries(double tag, Promise promise) {
|
|
75
|
+
UIManager uiManager = UIManagerHelper.getUIManagerForReactTag(getReactApplicationContext(), (int) tag);
|
|
76
|
+
getReactApplicationContext().runOnUiQueueThread(new Runnable() {
|
|
77
|
+
@Override
|
|
78
|
+
public void run() {
|
|
79
|
+
MapView view = (MapView) uiManager.resolveView((int) tag);
|
|
80
|
+
double[][] boundaries = view.getMapBoundaries();
|
|
81
|
+
WritableMap coordinates = new WritableNativeMap();
|
|
82
|
+
WritableMap northEastHash = new WritableNativeMap();
|
|
83
|
+
WritableMap southWestHash = new WritableNativeMap();
|
|
74
84
|
|
|
85
|
+
northEastHash.putDouble("longitude", boundaries[0][0]);
|
|
86
|
+
northEastHash.putDouble("latitude", boundaries[0][1]);
|
|
87
|
+
southWestHash.putDouble("longitude", boundaries[1][0]);
|
|
88
|
+
southWestHash.putDouble("latitude", boundaries[1][1]);
|
|
89
|
+
|
|
90
|
+
coordinates.putMap("northEast", northEastHash);
|
|
91
|
+
coordinates.putMap("southWest", southWestHash);
|
|
92
|
+
|
|
93
|
+
promise.resolve(coordinates);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
75
96
|
}
|
|
76
97
|
|
|
77
98
|
@Override
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package com.rnmaps.fabric.event;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.WritableMap;
|
|
6
|
+
import com.facebook.react.uimanager.events.Event;
|
|
7
|
+
|
|
8
|
+
public class OnRegionChangeCompleteEvent extends Event<OnRegionChangeCompleteEvent> {
|
|
9
|
+
public static final String EVENT_NAME = "topRegionChangeComplete";
|
|
10
|
+
|
|
11
|
+
private final WritableMap payload;
|
|
12
|
+
|
|
13
|
+
public OnRegionChangeCompleteEvent(int surfaceId, int viewId, WritableMap payload) {
|
|
14
|
+
super(surfaceId, viewId);
|
|
15
|
+
this.payload = payload;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@NonNull
|
|
19
|
+
@Override
|
|
20
|
+
public String getEventName() {
|
|
21
|
+
return EVENT_NAME;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
protected WritableMap getEventData() {
|
|
27
|
+
return payload;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.rnmaps.fabric.event;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.WritableMap;
|
|
6
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
7
|
+
import com.facebook.react.uimanager.events.Event;
|
|
8
|
+
import com.google.android.gms.maps.model.LatLng;
|
|
9
|
+
import com.google.android.gms.maps.model.LatLngBounds;
|
|
10
|
+
|
|
11
|
+
public class OnRegionChangeStartEvent extends Event<OnRegionChangeStartEvent> {
|
|
12
|
+
public static final String EVENT_NAME = "topRegionChangeStart";
|
|
13
|
+
|
|
14
|
+
private final WritableMap payload;
|
|
15
|
+
|
|
16
|
+
public OnRegionChangeStartEvent(int surfaceId, int viewId, WritableMap payload) {
|
|
17
|
+
super(surfaceId, viewId);
|
|
18
|
+
this.payload = payload;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@NonNull
|
|
22
|
+
@Override
|
|
23
|
+
public String getEventName() {
|
|
24
|
+
return EVENT_NAME;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@Override
|
|
29
|
+
protected WritableMap getEventData() {
|
|
30
|
+
return payload;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
@@ -4,14 +4,6 @@ import android.content.Context;
|
|
|
4
4
|
|
|
5
5
|
import com.facebook.react.common.MapBuilder;
|
|
6
6
|
import com.facebook.react.views.view.ReactViewGroup;
|
|
7
|
-
import com.rnmaps.fabric.event.OnLongPressEvent;
|
|
8
|
-
import com.rnmaps.fabric.event.OnMarkerDeselectEvent;
|
|
9
|
-
import com.rnmaps.fabric.event.OnMarkerDragEndEvent;
|
|
10
|
-
import com.rnmaps.fabric.event.OnMarkerDragEvent;
|
|
11
|
-
import com.rnmaps.fabric.event.OnMarkerDragStartEvent;
|
|
12
|
-
import com.rnmaps.fabric.event.OnMarkerPressEvent;
|
|
13
|
-
import com.rnmaps.fabric.event.OnMarkerSelectEvent;
|
|
14
|
-
import com.rnmaps.fabric.event.OnPoiClickEvent;
|
|
15
7
|
import com.rnmaps.fabric.event.OnPressEvent;
|
|
16
8
|
|
|
17
9
|
import java.util.Map;
|
|
@@ -33,6 +25,13 @@ public class MapCallout extends ReactViewGroup {
|
|
|
33
25
|
return this.tooltip;
|
|
34
26
|
}
|
|
35
27
|
|
|
28
|
+
@Override
|
|
29
|
+
protected void onLayout(boolean changed,
|
|
30
|
+
int left, int top, int right, int bottom){
|
|
31
|
+
width = right - left;
|
|
32
|
+
height = bottom - top;
|
|
33
|
+
}
|
|
34
|
+
|
|
36
35
|
|
|
37
36
|
public static Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
|
38
37
|
MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
|
|
@@ -253,16 +253,19 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
private <T extends Event> void dispatchEvent(WritableMap payload, EventCreator<T> creator) {
|
|
256
|
+
dispatchEvent(payload, creator, getId(), context);
|
|
257
|
+
}
|
|
258
|
+
public static <T extends Event> void dispatchEvent(WritableMap payload, EventCreator<T> creator, int viewId, ReactContext context){
|
|
256
259
|
// Cast context to ReactContext
|
|
257
260
|
ReactContext reactContext = context;
|
|
258
261
|
|
|
259
262
|
// Get the event dispatcher
|
|
260
|
-
EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext,
|
|
263
|
+
EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, viewId);
|
|
261
264
|
|
|
262
265
|
// If there is a dispatcher, create and dispatch the event
|
|
263
266
|
if (eventDispatcher != null) {
|
|
264
267
|
int surfaceId = UIManagerHelper.getSurfaceId(reactContext);
|
|
265
|
-
T event = creator.create(surfaceId,
|
|
268
|
+
T event = creator.create(surfaceId, viewId, payload);
|
|
266
269
|
eventDispatcher.dispatchEvent(event);
|
|
267
270
|
}
|
|
268
271
|
}
|
|
@@ -401,25 +404,22 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
401
404
|
}
|
|
402
405
|
});
|
|
403
406
|
|
|
404
|
-
markerCollection.setOnInfoWindowClickListener(
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
event.putString("action", "callout-press");
|
|
409
|
-
// todo: use Fabric events
|
|
410
|
-
// manager.pushEvent(context, view, "onCalloutPress", event);
|
|
407
|
+
markerCollection.setOnInfoWindowClickListener(marker -> {
|
|
408
|
+
WritableMap event = makeClickEventData(marker.getPosition());
|
|
409
|
+
event.putString("action", "callout-press");
|
|
410
|
+
dispatchEvent(event, OnCalloutPressEvent::new);
|
|
411
411
|
|
|
412
|
-
event = makeClickEventData(marker.getPosition());
|
|
413
|
-
event.putString("action", "callout-press");
|
|
414
|
-
MapMarker markerView = getMarkerMap(marker);
|
|
415
|
-
// todo: use Fabric events
|
|
416
|
-
// manager.pushEvent(context, markerView, "onCalloutPress", event);
|
|
417
412
|
|
|
413
|
+
event = makeClickEventData(marker.getPosition());
|
|
414
|
+
event.putString("action", "callout-press");
|
|
415
|
+
MapMarker markerView = getMarkerMap(marker);
|
|
416
|
+
dispatchEvent(event, OnCalloutPressEvent::new, markerView.getId(), context);
|
|
417
|
+
|
|
418
|
+
MapCallout infoWindow = markerView.getCalloutView();
|
|
419
|
+
if (infoWindow != null) {
|
|
418
420
|
event = makeClickEventData(marker.getPosition());
|
|
419
421
|
event.putString("action", "callout-press");
|
|
420
|
-
|
|
421
|
-
// todo: use Fabric events
|
|
422
|
-
// if (infoWindow != null) manager.pushEvent(context, infoWindow, "onPress", event);
|
|
422
|
+
dispatchEvent(event, OnPressEvent::new, infoWindow.getId(), context);
|
|
423
423
|
}
|
|
424
424
|
});
|
|
425
425
|
|
|
@@ -453,45 +453,32 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
453
453
|
}
|
|
454
454
|
});
|
|
455
455
|
|
|
456
|
-
map.setOnCameraMoveStartedListener(
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
event.putBoolean("isGesture", isGesture);
|
|
463
|
-
// todo: use Fabric events
|
|
464
|
-
// manager.pushEvent(context, view, "onRegionChangeStart", event);
|
|
465
|
-
}
|
|
456
|
+
map.setOnCameraMoveStartedListener(reason -> {
|
|
457
|
+
cameraMoveReason = reason;
|
|
458
|
+
boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == reason;
|
|
459
|
+
WritableMap event = new WritableNativeMap();
|
|
460
|
+
event.putBoolean("isGesture", isGesture);
|
|
461
|
+
dispatchEvent(event, OnRegionChangeStartEvent::new);
|
|
466
462
|
});
|
|
467
463
|
|
|
468
|
-
map.setOnCameraMoveListener(
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason;
|
|
475
|
-
WritableMap payload = OnRegionChangeEvent.payLoadFor(bounds, true, isGesture);
|
|
476
|
-
dispatchEvent(payload, OnRegionChangeEvent::new);
|
|
477
|
-
}
|
|
464
|
+
map.setOnCameraMoveListener(() -> {
|
|
465
|
+
LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
|
|
466
|
+
cameraLastIdleBounds = null;
|
|
467
|
+
boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason;
|
|
468
|
+
WritableMap payload = OnRegionChangeEvent.payLoadFor(bounds, false, isGesture);
|
|
469
|
+
dispatchEvent(payload, OnRegionChangeStartEvent::new);
|
|
478
470
|
});
|
|
479
471
|
|
|
480
|
-
map.setOnCameraIdleListener(
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
RegionChangeEvent event = new RegionChangeEvent(getId(), bounds, false, isGesture);
|
|
492
|
-
// todo: use Fabric events
|
|
493
|
-
// eventDispatcher.dispatchEvent(event);
|
|
494
|
-
}
|
|
472
|
+
map.setOnCameraIdleListener(() -> {
|
|
473
|
+
LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
|
|
474
|
+
if ((cameraMoveReason != 0) &&
|
|
475
|
+
((cameraLastIdleBounds == null) ||
|
|
476
|
+
LatLngBoundsUtils.BoundsAreDifferent(bounds, cameraLastIdleBounds))) {
|
|
477
|
+
|
|
478
|
+
cameraLastIdleBounds = bounds;
|
|
479
|
+
boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason;
|
|
480
|
+
WritableMap payload = OnRegionChangeEvent.payLoadFor(bounds, false, isGesture);
|
|
481
|
+
dispatchEvent(payload, OnRegionChangeCompleteEvent::new);
|
|
495
482
|
}
|
|
496
483
|
});
|
|
497
484
|
|
|
@@ -602,6 +589,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
602
589
|
builder.put(OnMarkerDragEndEvent.EVENT_NAME, MapBuilder.of("registrationName", OnMarkerDragEndEvent.EVENT_NAME));
|
|
603
590
|
builder.put(OnPoiClickEvent.EVENT_NAME, MapBuilder.of("registrationName", OnPoiClickEvent.EVENT_NAME));
|
|
604
591
|
builder.put(OnLongPressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnLongPressEvent.EVENT_NAME));
|
|
592
|
+
builder.put(OnLongPressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnRegionChangeStartEvent.EVENT_NAME));
|
|
593
|
+
builder.put(OnLongPressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnRegionChangeCompleteEvent.EVENT_NAME));
|
|
605
594
|
return builder.build();
|
|
606
595
|
}
|
|
607
596
|
|
package/lib/MapView.d.ts
CHANGED
|
@@ -692,6 +692,8 @@ declare class MapView extends React.Component<MapViewProps, State> {
|
|
|
692
692
|
private handleMarkerSelect;
|
|
693
693
|
private handleMarkerDeselect;
|
|
694
694
|
private handleRegionChange;
|
|
695
|
+
private handleRegionChangeStarted;
|
|
696
|
+
private handleRegionChangeComplete;
|
|
695
697
|
render(): React.JSX.Element;
|
|
696
698
|
}
|
|
697
699
|
export declare const AnimatedMapView: RNAnimated.AnimatedComponent<typeof MapView>;
|
package/lib/MapView.js
CHANGED
|
@@ -156,13 +156,8 @@ class MapView extends React.Component {
|
|
|
156
156
|
* @return Promise Promise with the bounding box ({ northEast: <LatLng>, southWest: <LatLng> })
|
|
157
157
|
*/
|
|
158
158
|
async getMapBoundaries() {
|
|
159
|
-
if (
|
|
160
|
-
return
|
|
161
|
-
}
|
|
162
|
-
else if (react_native_1.Platform.OS === 'ios') {
|
|
163
|
-
if (this.fabricMap.current) {
|
|
164
|
-
return this.fabricMap.current.getMapBoundaries();
|
|
165
|
-
}
|
|
159
|
+
if (this.fabricMap.current) {
|
|
160
|
+
return this.fabricMap.current.getMapBoundaries();
|
|
166
161
|
}
|
|
167
162
|
return Promise.reject('getMapBoundaries not supported on this platform');
|
|
168
163
|
}
|
|
@@ -342,6 +337,18 @@ class MapView extends React.Component {
|
|
|
342
337
|
this.props.onRegionChangeComplete(event.nativeEvent.region, details);
|
|
343
338
|
}
|
|
344
339
|
};
|
|
340
|
+
handleRegionChangeStarted = (event) => {
|
|
341
|
+
if (this.props.onRegionChangeStart) {
|
|
342
|
+
this.props.onRegionChangeStart(event);
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
handleRegionChangeComplete = (event) => {
|
|
346
|
+
const isGesture = event.nativeEvent.isGesture;
|
|
347
|
+
const details = { isGesture };
|
|
348
|
+
if (this.props.onRegionChangeComplete) {
|
|
349
|
+
this.props.onRegionChangeComplete(event.nativeEvent.region, details);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
345
352
|
render() {
|
|
346
353
|
// Define props specifically for MapFabricNativeProps
|
|
347
354
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
@@ -361,6 +368,8 @@ class MapView extends React.Component {
|
|
|
361
368
|
minZoom: minZoomLevel,
|
|
362
369
|
maxZoom: maxZoomLevel,
|
|
363
370
|
onRegionChange: this.handleRegionChange,
|
|
371
|
+
onRegionChangeStart: this.handleRegionChangeStarted,
|
|
372
|
+
onRegionChangeComplete: this.handleRegionChangeComplete,
|
|
364
373
|
...restProps,
|
|
365
374
|
};
|
|
366
375
|
if (this.props.region) {
|
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.69",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|