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.
@@ -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(new GoogleMap.OnCameraMoveStartedListener() {
457
- @Override
458
- public void onCameraMoveStarted(int reason) {
459
- cameraMoveReason = reason;
460
- boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == reason;
461
- WritableMap event = new WritableNativeMap();
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(new GoogleMap.OnCameraMoveListener() {
470
- @Override
471
- public void onCameraMove() {
472
- LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
473
-
474
- cameraLastIdleBounds = null;
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(new GoogleMap.OnCameraIdleListener() {
482
- @Override
483
- public void onCameraIdle() {
484
- LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
485
- if ((cameraMoveReason != 0) &&
486
- ((cameraLastIdleBounds == null) ||
487
- LatLngBoundsUtils.BoundsAreDifferent(bounds, cameraLastIdleBounds))) {
488
-
489
- cameraLastIdleBounds = bounds;
490
- boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason;
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 (react_native_1.Platform.OS === 'android') {
160
- return await react_native_1.NativeModules.AirMapModule.getMapBoundaries(this._getHandle());
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.68",
8
+ "version": "1.21.0-alpha.69",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",