react-native-maps 1.21.0-alpha.68 → 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/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/MapView.java +24 -36
- package/lib/MapView.d.ts +2 -0
- package/lib/MapView.js +16 -7
- package/package.json +1 -1
|
@@ -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
|
+
}
|
|
@@ -453,46 +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
|
-
// dispatchEvent(event, OnRegionChangeEvent::new);
|
|
464
|
-
// todo: use Fabric events
|
|
465
|
-
// manager.pushEvent(context, view, "onRegionChangeStart", event);
|
|
466
|
-
}
|
|
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);
|
|
467
462
|
});
|
|
468
463
|
|
|
469
|
-
map.setOnCameraMoveListener(
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason;
|
|
476
|
-
WritableMap payload = OnRegionChangeEvent.payLoadFor(bounds, true, isGesture);
|
|
477
|
-
dispatchEvent(payload, OnRegionChangeEvent::new);
|
|
478
|
-
}
|
|
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);
|
|
479
470
|
});
|
|
480
471
|
|
|
481
|
-
map.setOnCameraIdleListener(
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
RegionChangeEvent event = new RegionChangeEvent(getId(), bounds, false, isGesture);
|
|
493
|
-
// todo: use Fabric events
|
|
494
|
-
// eventDispatcher.dispatchEvent(event);
|
|
495
|
-
}
|
|
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);
|
|
496
482
|
}
|
|
497
483
|
});
|
|
498
484
|
|
|
@@ -603,6 +589,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
603
589
|
builder.put(OnMarkerDragEndEvent.EVENT_NAME, MapBuilder.of("registrationName", OnMarkerDragEndEvent.EVENT_NAME));
|
|
604
590
|
builder.put(OnPoiClickEvent.EVENT_NAME, MapBuilder.of("registrationName", OnPoiClickEvent.EVENT_NAME));
|
|
605
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));
|
|
606
594
|
return builder.build();
|
|
607
595
|
}
|
|
608
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",
|