react-native-maps 1.25.0-alpha.8 → 1.25.0
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/README.md +2 -53
- package/android/src/main/RCTThirdPartyComponentsProvider.mm +0 -2
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCircleManagerDelegate.java +1 -1
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsGooglePolygonManagerDelegate.java +3 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsGooglePolygonManagerInterface.java +1 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerDelegate.java +6 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerInterface.java +2 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsPolylineManagerDelegate.java +1 -1
- package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +1 -1
- package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +41 -5
- package/android/src/main/java/com/rnmaps/fabric/PolygonManager.java +9 -2
- package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeEvent.java +1 -2
- package/android/src/main/java/com/rnmaps/maps/MapMarker.java +46 -3
- package/android/src/main/java/com/rnmaps/maps/MapPolyline.java +8 -1
- package/android/src/main/java/com/rnmaps/maps/MapView.java +104 -51
- package/android/src/main/java/com/rnmaps/maps/MapsPackage.java +84 -27
- package/android/src/main/java/com/rnmaps/maps/RegionChangeEvent.java +1 -4
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +6 -6
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +6 -6
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.cpp +5 -2
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.h +27 -2
- package/ios/AirGoogleMaps/AIRGoogleMap.mm +13 -12
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +4 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +3 -3
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +6 -6
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +4 -4
- package/ios/AirMaps/AIRMap.h +2 -1
- package/ios/AirMaps/AIRMapManager.m +34 -18
- package/ios/AirMaps/AIRMapMarker.m +7 -1
- package/ios/AirMaps/FabricPlaceholders/PlaceHolderGoogleMapView.mm +2 -2
- package/ios/AirMaps/FabricPlaceholders/PlaceHolderPolygonView.mm +1 -1
- package/ios/AirMaps/RNMapsAirModule.mm +3 -3
- package/ios/AirMaps/RNMapsMapView.h +4 -4
- package/ios/AirMaps/RNMapsMapView.mm +55 -10
- package/ios/AirMaps/RNMapsMapViewManager.mm +1 -1
- package/ios/AirMaps/RNMapsMarkerView.mm +4 -3
- package/ios/generated/RNMapsAirModuleDelegate.h +1 -1
- package/ios/generated/{RNMapsHostVewDelegate.h → RNMapsHostViewDelegate.h} +1 -1
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +2 -0
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +2 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.cpp +8 -6
- package/ios/generated/RNMapsSpecs/EventEmitters.h +20 -6
- package/ios/generated/RNMapsSpecs/Props.cpp +37 -2
- package/ios/generated/RNMapsSpecs/Props.h +110 -13
- package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +2 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.h +22 -0
- package/ios/generated/RNMapsSpecs/States.h +24 -0
- package/ios/generated/module.modulemap +1 -1
- package/package.json +9 -3
- package/plugin/build/ios.js +3 -3
- package/src/AnimatedRegion.ts +3 -1
- package/src/Geojson.tsx +5 -5
- package/src/MapCallout.tsx +5 -5
- package/src/MapCalloutSubview.tsx +9 -5
- package/src/MapCircle.tsx +5 -5
- package/src/MapHeatmap.tsx +11 -6
- package/src/MapLocalTile.tsx +4 -4
- package/src/MapMarker.tsx +38 -17
- package/src/MapMarkerNativeComponent.ts +3 -2
- package/src/MapOverlay.tsx +10 -10
- package/src/MapPolygon.tsx +6 -6
- package/src/MapPolygon.types.ts +2 -2
- package/src/MapPolyline.tsx +5 -5
- package/src/MapUrlTile.tsx +4 -4
- package/src/MapView.tsx +34 -37
- package/src/MapView.types.ts +2 -3
- package/src/MapViewNativeComponent.ts +3 -3
- package/src/MapWMSTile.tsx +4 -4
- package/src/createFabricMap.tsx +39 -37
- package/src/decorateMapComponent.ts +9 -3
- package/src/fixImageProp.ts +1 -1
- package/src/index.ts +1 -1
- package/src/sharedTypes.ts +1 -1
- package/src/specs/NativeAirMapsModule.ts +1 -1
- package/src/specs/NativeComponentCallout.ts +1 -1
- package/src/specs/NativeComponentCircle.ts +3 -2
- package/src/specs/NativeComponentGoogleMapView.ts +12 -10
- package/src/specs/NativeComponentGooglePolygon.ts +12 -1
- package/src/specs/NativeComponentMapView.ts +12 -10
- package/src/specs/NativeComponentMarker.ts +26 -2
- package/src/specs/NativeComponentOverlay.ts +1 -1
- package/src/specs/NativeComponentPolyline.ts +2 -2
- package/src/specs/NativeComponentUrlTile.ts +4 -1
- package/src/specs/NativeComponentWMSTile.ts +4 -1
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +0 -98
- package/ios/AirMaps.xcodeproj/project.pbxproj +0 -627
|
@@ -13,6 +13,7 @@ import android.location.Location;
|
|
|
13
13
|
import androidx.lifecycle.DefaultLifecycleObserver;
|
|
14
14
|
import androidx.lifecycle.LifecycleOwner;
|
|
15
15
|
|
|
16
|
+
import android.os.Bundle;
|
|
16
17
|
import android.view.GestureDetector;
|
|
17
18
|
import android.view.MotionEvent;
|
|
18
19
|
import android.view.View;
|
|
@@ -24,8 +25,6 @@ import android.widget.RelativeLayout;
|
|
|
24
25
|
import androidx.annotation.NonNull;
|
|
25
26
|
import androidx.annotation.Nullable;
|
|
26
27
|
import androidx.core.content.PermissionChecker;
|
|
27
|
-
import androidx.core.view.GestureDetectorCompat;
|
|
28
|
-
import androidx.core.view.MotionEventCompat;
|
|
29
28
|
|
|
30
29
|
import com.facebook.react.common.MapBuilder;
|
|
31
30
|
|
|
@@ -90,6 +89,9 @@ import com.rnmaps.fabric.event.*;
|
|
|
90
89
|
public class MapView extends com.google.android.gms.maps.MapView implements GoogleMap.InfoWindowAdapter,
|
|
91
90
|
GoogleMap.OnMarkerDragListener, OnMapReadyCallback, GoogleMap.OnPoiClickListener, GoogleMap.OnIndoorStateChangeListener, DefaultLifecycleObserver {
|
|
92
91
|
public GoogleMap map;
|
|
92
|
+
private Bundle savedMapState;
|
|
93
|
+
private Map<Integer, MapFeature> savedFeatures = new HashMap<>();
|
|
94
|
+
|
|
93
95
|
private MarkerManager markerManager;
|
|
94
96
|
private MarkerManager.Collection markerCollection;
|
|
95
97
|
private PolylineManager polylineManager;
|
|
@@ -128,27 +130,29 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
128
130
|
private String customMapStyleString;
|
|
129
131
|
private boolean initialRegionSet = false;
|
|
130
132
|
private boolean initialCameraSet = false;
|
|
131
|
-
private
|
|
132
|
-
private int cameraMoveReason = 0;
|
|
133
|
+
private int cameraMoveReason = -1;
|
|
133
134
|
private MapMarker selectedMarker;
|
|
134
135
|
|
|
136
|
+
private LifecycleOwner currentLifecycleOwner;
|
|
137
|
+
private boolean isLifecycleObserverAttached = false;
|
|
138
|
+
|
|
135
139
|
private static final String[] PERMISSIONS = new String[]{
|
|
136
140
|
"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"};
|
|
137
141
|
|
|
138
|
-
private final
|
|
142
|
+
private final Map<Integer, MapFeature> features = new HashMap<>();
|
|
139
143
|
private final Map<Marker, MapMarker> markerMap = new HashMap<>();
|
|
140
144
|
private final Map<Polyline, MapPolyline> polylineMap = new HashMap<>();
|
|
141
145
|
private final Map<Polygon, MapPolygon> polygonMap = new HashMap<>();
|
|
142
146
|
private final Map<GroundOverlay, MapOverlay> overlayMap = new HashMap<>();
|
|
143
147
|
private final Map<TileOverlay, MapHeatmap> heatmapMap = new HashMap<>();
|
|
144
148
|
private final Map<TileOverlay, MapGradientPolyline> gradientPolylineMap = new HashMap<>();
|
|
145
|
-
private final
|
|
149
|
+
private final GestureDetector gestureDetector;
|
|
146
150
|
private boolean paused = false;
|
|
147
151
|
private boolean destroyed = false;
|
|
148
152
|
private final ThemedReactContext context;
|
|
149
153
|
private final FusedLocationSource fusedLocationSource;
|
|
150
154
|
|
|
151
|
-
private
|
|
155
|
+
private ViewAttacherGroup attacherGroup;
|
|
152
156
|
private LatLng tapLocation;
|
|
153
157
|
private Float maxZoomLevel;
|
|
154
158
|
private Float minZoomLevel;
|
|
@@ -250,10 +254,6 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
250
254
|
GoogleMapOptions googleMapOptions) {
|
|
251
255
|
super(context, googleMapOptions);
|
|
252
256
|
this.context = context;
|
|
253
|
-
Activity activity = context.getCurrentActivity();
|
|
254
|
-
if (activity instanceof LifecycleOwner) {
|
|
255
|
-
((LifecycleOwner) activity).getLifecycle().addObserver(this);
|
|
256
|
-
}
|
|
257
257
|
super.getMapAsync(this);
|
|
258
258
|
|
|
259
259
|
final MapView view = this;
|
|
@@ -261,7 +261,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
261
261
|
fusedLocationSource = new FusedLocationSource(context);
|
|
262
262
|
|
|
263
263
|
gestureDetector =
|
|
264
|
-
new
|
|
264
|
+
new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
|
|
265
265
|
|
|
266
266
|
@Override
|
|
267
267
|
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
|
|
@@ -292,6 +292,10 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
292
292
|
|
|
293
293
|
// Set up a parent view for triggering visibility in subviews that depend on it.
|
|
294
294
|
// Mainly ReactImageView depends on Fresco which depends on onVisibilityChanged() event
|
|
295
|
+
prepareAttacherView();
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
private void prepareAttacherView(){
|
|
295
299
|
attacherGroup = new ViewAttacherGroup(context);
|
|
296
300
|
LayoutParams attacherLayoutParams = new LayoutParams(0, 0);
|
|
297
301
|
attacherLayoutParams.width = 0;
|
|
@@ -309,12 +313,66 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
309
313
|
|
|
310
314
|
}
|
|
311
315
|
|
|
316
|
+
@Override
|
|
317
|
+
protected void onAttachedToWindow() {
|
|
318
|
+
super.onAttachedToWindow();
|
|
319
|
+
attachLifecycleObserver();
|
|
320
|
+
if (savedMapState != null) {
|
|
321
|
+
super.onCreate(savedMapState);
|
|
322
|
+
super.onStart();
|
|
323
|
+
super.onResume();
|
|
324
|
+
prepareAttacherView();
|
|
325
|
+
getMapAsync((map)->{
|
|
326
|
+
onMapReady(map);
|
|
327
|
+
savedFeatures.forEach((index, feature) -> {
|
|
328
|
+
addFeature(feature, index);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Override onDetachedFromWindow to detach lifecycle observer
|
|
335
|
+
@Override
|
|
336
|
+
protected void onDetachedFromWindow() {
|
|
337
|
+
if (savedMapState == null) {
|
|
338
|
+
savedMapState = new Bundle();
|
|
339
|
+
}
|
|
340
|
+
super.onSaveInstanceState(savedMapState);
|
|
341
|
+
super.onPause();
|
|
342
|
+
super.onStop();
|
|
343
|
+
savedFeatures = new HashMap<>(features);
|
|
344
|
+
savedFeatures.keySet().forEach(this::removeFeatureAt);
|
|
345
|
+
removeView(attacherGroup);
|
|
346
|
+
attacherGroup = null;
|
|
347
|
+
detachLifecycleObserver();
|
|
348
|
+
super.onDetachedFromWindow();
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Method to attach lifecycle observer
|
|
352
|
+
private void attachLifecycleObserver() {
|
|
353
|
+
Activity activity = context.getCurrentActivity();
|
|
354
|
+
if (activity instanceof LifecycleOwner && !isLifecycleObserverAttached) {
|
|
355
|
+
currentLifecycleOwner = (LifecycleOwner) activity;
|
|
356
|
+
currentLifecycleOwner.getLifecycle().addObserver(this);
|
|
357
|
+
isLifecycleObserverAttached = true;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Method to detach lifecycle observer
|
|
362
|
+
private void detachLifecycleObserver() {
|
|
363
|
+
if (currentLifecycleOwner != null && isLifecycleObserverAttached) {
|
|
364
|
+
currentLifecycleOwner.getLifecycle().removeObserver(this);
|
|
365
|
+
isLifecycleObserverAttached = false;
|
|
366
|
+
currentLifecycleOwner = null;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
312
370
|
public double[][] getMarkersFrames(boolean onlyVisible) {
|
|
313
371
|
|
|
314
372
|
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
|
315
373
|
boolean addedPosition = false;
|
|
316
374
|
LatLngBounds mapBounds = map.getProjection().getVisibleRegion().latLngBounds;
|
|
317
|
-
for (MapFeature feature : features) {
|
|
375
|
+
for (MapFeature feature : features.values()) {
|
|
318
376
|
if (feature instanceof MapMarker) {
|
|
319
377
|
Marker marker = (Marker) feature.getFeature();
|
|
320
378
|
if (!onlyVisible ||
|
|
@@ -459,7 +517,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
459
517
|
MapMarker airMapMarker = getMarkerMap(marker);
|
|
460
518
|
|
|
461
519
|
WritableMap eventData = makeClickEventData(marker.getPosition());
|
|
462
|
-
eventData.putString("action", "press");
|
|
520
|
+
eventData.putString("action", "marker-press");
|
|
463
521
|
eventData.putString("id", airMapMarker.getIdentifier());
|
|
464
522
|
airMapMarker.dispatchEvent(eventData, OnPressEvent::new);
|
|
465
523
|
|
|
@@ -563,31 +621,25 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
563
621
|
|
|
564
622
|
map.setOnCameraMoveStartedListener(reason -> {
|
|
565
623
|
cameraMoveReason = reason;
|
|
624
|
+
LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
|
|
566
625
|
boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == reason;
|
|
567
|
-
WritableMap
|
|
568
|
-
|
|
569
|
-
dispatchEvent(event, OnRegionChangeStartEvent::new);
|
|
626
|
+
WritableMap payload = OnRegionChangeEvent.payLoadFor(bounds, isGesture);
|
|
627
|
+
dispatchEvent(payload, OnRegionChangeStartEvent::new);
|
|
570
628
|
});
|
|
571
629
|
|
|
572
630
|
map.setOnCameraMoveListener(() -> {
|
|
573
|
-
LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
|
|
574
|
-
cameraLastIdleBounds = null;
|
|
575
631
|
boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason;
|
|
576
|
-
|
|
577
|
-
|
|
632
|
+
LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
|
|
633
|
+
WritableMap payload = OnRegionChangeEvent.payLoadFor(bounds, isGesture);
|
|
634
|
+
dispatchEvent(payload, OnRegionChangeEvent::new);
|
|
578
635
|
});
|
|
579
636
|
|
|
580
637
|
map.setOnCameraIdleListener(() -> {
|
|
638
|
+
boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason;
|
|
639
|
+
cameraMoveReason = -1;
|
|
581
640
|
LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
LatLngBoundsUtils.BoundsAreDifferent(bounds, cameraLastIdleBounds))) {
|
|
585
|
-
|
|
586
|
-
cameraLastIdleBounds = bounds;
|
|
587
|
-
boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason;
|
|
588
|
-
WritableMap payload = OnRegionChangeEvent.payLoadFor(bounds, false, isGesture);
|
|
589
|
-
dispatchEvent(payload, OnRegionChangeCompleteEvent::new);
|
|
590
|
-
}
|
|
641
|
+
WritableMap payload = OnRegionChangeEvent.payLoadFor(bounds, isGesture);
|
|
642
|
+
dispatchEvent(payload, OnRegionChangeCompleteEvent::new);
|
|
591
643
|
});
|
|
592
644
|
|
|
593
645
|
map.setOnMapLoadedCallback(() -> {
|
|
@@ -689,10 +741,11 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
689
741
|
}
|
|
690
742
|
destroyed = true;
|
|
691
743
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
744
|
+
// Detach lifecycle observer before destroying
|
|
745
|
+
detachLifecycleObserver();
|
|
746
|
+
savedMapState = null;
|
|
747
|
+
savedFeatures = null;
|
|
748
|
+
|
|
696
749
|
if (!paused) {
|
|
697
750
|
onPause();
|
|
698
751
|
paused = true;
|
|
@@ -1063,7 +1116,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
1063
1116
|
if (child instanceof MapMarker) {
|
|
1064
1117
|
MapMarker annotation = (MapMarker) child;
|
|
1065
1118
|
annotation.addToMap(markerCollection);
|
|
1066
|
-
features.
|
|
1119
|
+
features.put(index, annotation);
|
|
1067
1120
|
|
|
1068
1121
|
// Allow visibility event to be triggered later
|
|
1069
1122
|
int visibility = annotation.getVisibility();
|
|
@@ -1089,47 +1142,47 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
1089
1142
|
} else if (child instanceof MapPolyline) {
|
|
1090
1143
|
MapPolyline polylineView = (MapPolyline) child;
|
|
1091
1144
|
polylineView.addToMap(polylineCollection);
|
|
1092
|
-
features.
|
|
1145
|
+
features.put(index, polylineView);
|
|
1093
1146
|
Polyline polyline = (Polyline) polylineView.getFeature();
|
|
1094
1147
|
polylineMap.put(polyline, polylineView);
|
|
1095
1148
|
} else if (child instanceof MapGradientPolyline) {
|
|
1096
1149
|
MapGradientPolyline polylineView = (MapGradientPolyline) child;
|
|
1097
1150
|
polylineView.addToMap(map);
|
|
1098
|
-
features.
|
|
1151
|
+
features.put(index, polylineView);
|
|
1099
1152
|
TileOverlay tileOverlay = (TileOverlay) polylineView.getFeature();
|
|
1100
1153
|
gradientPolylineMap.put(tileOverlay, polylineView);
|
|
1101
1154
|
} else if (child instanceof MapPolygon) {
|
|
1102
1155
|
MapPolygon polygonView = (MapPolygon) child;
|
|
1103
1156
|
polygonView.addToMap(polygonCollection);
|
|
1104
|
-
features.
|
|
1157
|
+
features.put(index, polygonView);
|
|
1105
1158
|
Polygon polygon = (Polygon) polygonView.getFeature();
|
|
1106
1159
|
polygonMap.put(polygon, polygonView);
|
|
1107
1160
|
} else if (child instanceof MapCircle) {
|
|
1108
1161
|
MapCircle circleView = (MapCircle) child;
|
|
1109
1162
|
circleView.addToMap(circleCollection);
|
|
1110
|
-
features.
|
|
1163
|
+
features.put(index, circleView);
|
|
1111
1164
|
} else if (child instanceof MapUrlTile) {
|
|
1112
1165
|
MapUrlTile urlTileView = (MapUrlTile) child;
|
|
1113
1166
|
urlTileView.addToMap(map);
|
|
1114
|
-
features.
|
|
1167
|
+
features.put(index, urlTileView);
|
|
1115
1168
|
} else if (child instanceof MapWMSTile) {
|
|
1116
1169
|
MapWMSTile urlTileView = (MapWMSTile) child;
|
|
1117
1170
|
urlTileView.addToMap(map);
|
|
1118
|
-
features.
|
|
1171
|
+
features.put(index, urlTileView);
|
|
1119
1172
|
} else if (child instanceof MapLocalTile) {
|
|
1120
1173
|
MapLocalTile localTileView = (MapLocalTile) child;
|
|
1121
1174
|
localTileView.addToMap(map);
|
|
1122
|
-
features.
|
|
1175
|
+
features.put(index, localTileView);
|
|
1123
1176
|
} else if (child instanceof MapOverlay) {
|
|
1124
1177
|
MapOverlay overlayView = (MapOverlay) child;
|
|
1125
1178
|
overlayView.addToMap(groundOverlayCollection);
|
|
1126
|
-
features.
|
|
1179
|
+
features.put(index, overlayView);
|
|
1127
1180
|
GroundOverlay overlay = (GroundOverlay) overlayView.getFeature();
|
|
1128
1181
|
overlayMap.put(overlay, overlayView);
|
|
1129
1182
|
} else if (child instanceof MapHeatmap) {
|
|
1130
1183
|
MapHeatmap heatmapView = (MapHeatmap) child;
|
|
1131
1184
|
heatmapView.addToMap(map);
|
|
1132
|
-
features.
|
|
1185
|
+
features.put(index, heatmapView);
|
|
1133
1186
|
TileOverlay heatmap = (TileOverlay) heatmapView.getFeature();
|
|
1134
1187
|
heatmapMap.put(heatmap, heatmapView);
|
|
1135
1188
|
} else if (child instanceof ViewGroup) {
|
|
@@ -1274,8 +1327,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
1274
1327
|
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
|
1275
1328
|
|
|
1276
1329
|
boolean addedPosition = false;
|
|
1277
|
-
if (features.
|
|
1278
|
-
for (MapFeature feature : features) {
|
|
1330
|
+
if (!features.isEmpty()) {
|
|
1331
|
+
for (MapFeature feature : features.values()) {
|
|
1279
1332
|
if (feature instanceof MapMarker) {
|
|
1280
1333
|
Marker marker = (Marker) feature.getFeature();
|
|
1281
1334
|
builder.include(marker.getPosition());
|
|
@@ -1317,7 +1370,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
1317
1370
|
|
|
1318
1371
|
List<String> markerIDList = Arrays.asList(markerIDs);
|
|
1319
1372
|
|
|
1320
|
-
for (MapFeature feature : features) {
|
|
1373
|
+
for (MapFeature feature : features.values()) {
|
|
1321
1374
|
if (feature instanceof MapMarker) {
|
|
1322
1375
|
String identifier = ((MapMarker) feature).getIdentifier();
|
|
1323
1376
|
Marker marker = (Marker) feature.getFeature();
|
|
@@ -1489,7 +1542,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
1489
1542
|
tapLocation = map.getProjection().fromScreenLocation(new Point(X, Y));
|
|
1490
1543
|
}
|
|
1491
1544
|
|
|
1492
|
-
int action =
|
|
1545
|
+
int action = ev.getActionMasked();
|
|
1493
1546
|
|
|
1494
1547
|
switch (action) {
|
|
1495
1548
|
case (MotionEvent.ACTION_DOWN):
|
|
@@ -1512,7 +1565,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
1512
1565
|
|
|
1513
1566
|
MapMarker markerView = getMarkerMap(marker);
|
|
1514
1567
|
event = makeClickEventData(marker.getPosition());
|
|
1515
|
-
dispatchEvent(event,
|
|
1568
|
+
markerView.dispatchEvent(event, OnDragStartEvent::new);
|
|
1516
1569
|
}
|
|
1517
1570
|
|
|
1518
1571
|
@Override
|
|
@@ -1522,7 +1575,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
1522
1575
|
|
|
1523
1576
|
MapMarker markerView = getMarkerMap(marker);
|
|
1524
1577
|
event = makeClickEventData(marker.getPosition());
|
|
1525
|
-
dispatchEvent(event,
|
|
1578
|
+
markerView.dispatchEvent(event, OnDragEvent::new);
|
|
1526
1579
|
}
|
|
1527
1580
|
|
|
1528
1581
|
@Override
|
|
@@ -1531,7 +1584,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
1531
1584
|
dispatchEvent(event, OnMarkerDragEndEvent::new);
|
|
1532
1585
|
MapMarker markerView = getMarkerMap(marker);
|
|
1533
1586
|
event = makeClickEventData(marker.getPosition());
|
|
1534
|
-
dispatchEvent(event,
|
|
1587
|
+
markerView.dispatchEvent(event, OnDragEndEvent::new);
|
|
1535
1588
|
}
|
|
1536
1589
|
|
|
1537
1590
|
@Override
|
|
@@ -1,45 +1,102 @@
|
|
|
1
1
|
package com.rnmaps.maps;
|
|
2
2
|
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.fbreact.specs.NativeAirMapsModuleSpec;
|
|
6
|
+
import com.facebook.react.BaseReactPackage;
|
|
3
7
|
import com.facebook.react.ReactPackage;
|
|
4
8
|
import com.facebook.react.bridge.NativeModule;
|
|
5
9
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
+
import com.facebook.react.module.model.ReactModuleInfo;
|
|
11
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
6
12
|
import com.facebook.react.uimanager.ViewManager;
|
|
13
|
+
import com.rnmaps.fabric.CalloutManager;
|
|
14
|
+
import com.rnmaps.fabric.CircleManager;
|
|
15
|
+
import com.rnmaps.fabric.MapViewManager;
|
|
16
|
+
import com.rnmaps.fabric.MarkerManager;
|
|
17
|
+
import com.rnmaps.fabric.NativeAirMapsModule;
|
|
18
|
+
import com.rnmaps.fabric.OverlayManager;
|
|
19
|
+
import com.rnmaps.fabric.PolygonManager;
|
|
20
|
+
import com.rnmaps.fabric.PolylineManager;
|
|
21
|
+
import com.rnmaps.fabric.UrlTileManager;
|
|
22
|
+
import com.rnmaps.fabric.WMSTileManager;
|
|
7
23
|
|
|
8
|
-
import java.util.
|
|
24
|
+
import java.util.HashMap;
|
|
9
25
|
import java.util.List;
|
|
26
|
+
import java.util.Map;
|
|
10
27
|
|
|
11
|
-
public class MapsPackage implements ReactPackage {
|
|
28
|
+
public class MapsPackage extends BaseReactPackage implements ReactPackage {
|
|
12
29
|
|
|
13
30
|
@Override
|
|
14
|
-
public List<
|
|
15
|
-
List
|
|
31
|
+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
32
|
+
return List.of(new MapViewManager(reactContext),
|
|
33
|
+
new MarkerManager(reactContext),
|
|
34
|
+
new CalloutManager(reactContext),
|
|
35
|
+
new PolygonManager(reactContext),
|
|
36
|
+
new PolylineManager(reactContext),
|
|
37
|
+
new CircleManager(reactContext),
|
|
38
|
+
new OverlayManager(reactContext),
|
|
39
|
+
new UrlTileManager(reactContext),
|
|
40
|
+
new WMSTileManager(reactContext),
|
|
41
|
+
new MapGradientPolylineManager(reactContext),
|
|
42
|
+
new MapLocalTileManager(reactContext),
|
|
43
|
+
new MapHeatmapManager());
|
|
44
|
+
}
|
|
16
45
|
|
|
17
|
-
modules.add(new MapModule(reactContext));
|
|
18
46
|
|
|
19
|
-
|
|
47
|
+
@Override
|
|
48
|
+
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
|
|
49
|
+
if (OverlayManager.REACT_CLASS.equals(name)) {
|
|
50
|
+
return new OverlayManager(reactContext);
|
|
51
|
+
}
|
|
52
|
+
if (CircleManager.REACT_CLASS.equals(name)) {
|
|
53
|
+
return new CircleManager(reactContext);
|
|
54
|
+
}
|
|
55
|
+
if (PolylineManager.REACT_CLASS.equals(name)) {
|
|
56
|
+
return new PolylineManager(reactContext);
|
|
57
|
+
}
|
|
58
|
+
if (PolygonManager.REACT_CLASS.equals(name)) {
|
|
59
|
+
return new PolygonManager(reactContext);
|
|
60
|
+
}
|
|
61
|
+
if (CalloutManager.REACT_CLASS.equals(name)) {
|
|
62
|
+
return new CalloutManager(reactContext);
|
|
63
|
+
}
|
|
64
|
+
if (MarkerManager.REACT_CLASS.equals(name)) {
|
|
65
|
+
return new MarkerManager(reactContext);
|
|
66
|
+
}
|
|
67
|
+
if (MapViewManager.REACT_CLASS.equals(name)) {
|
|
68
|
+
return new MapViewManager(reactContext);
|
|
69
|
+
}
|
|
70
|
+
if (UrlTileManager.REACT_CLASS.equals(name)) {
|
|
71
|
+
return new UrlTileManager(reactContext);
|
|
72
|
+
}
|
|
73
|
+
if (WMSTileManager.REACT_CLASS.equals(name)) {
|
|
74
|
+
return new WMSTileManager(reactContext);
|
|
75
|
+
}
|
|
76
|
+
if (NativeAirMapsModuleSpec.NAME.equals(name)) {
|
|
77
|
+
return new NativeAirMapsModule(reactContext);
|
|
78
|
+
} else {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
20
81
|
}
|
|
21
82
|
|
|
22
83
|
@Override
|
|
23
|
-
public
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
viewManagers.add(new MapOverlayManager(reactContext));
|
|
41
|
-
viewManagers.add(new MapHeatmapManager());
|
|
42
|
-
|
|
43
|
-
return viewManagers;
|
|
84
|
+
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
|
85
|
+
return new ReactModuleInfoProvider() {
|
|
86
|
+
@NonNull
|
|
87
|
+
@Override
|
|
88
|
+
public Map<String, ReactModuleInfo> getReactModuleInfos() {
|
|
89
|
+
Map<String, ReactModuleInfo> map = new HashMap<>();
|
|
90
|
+
map.put(NativeAirMapsModuleSpec.NAME, new ReactModuleInfo(
|
|
91
|
+
NativeAirMapsModuleSpec.NAME, // name
|
|
92
|
+
NativeAirMapsModuleSpec.NAME, // className
|
|
93
|
+
false, // canOverrideExistingModule
|
|
94
|
+
false, // needsEagerInit
|
|
95
|
+
false, // isCXXModule
|
|
96
|
+
true // isTurboModule
|
|
97
|
+
));
|
|
98
|
+
return map;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
44
101
|
}
|
|
45
102
|
}
|
|
@@ -9,13 +9,11 @@ import com.google.android.gms.maps.model.LatLngBounds;
|
|
|
9
9
|
|
|
10
10
|
public class RegionChangeEvent extends Event<RegionChangeEvent> {
|
|
11
11
|
private final LatLngBounds bounds;
|
|
12
|
-
private final boolean continuous;
|
|
13
12
|
private final boolean isGesture;
|
|
14
13
|
|
|
15
|
-
public RegionChangeEvent(int id, LatLngBounds bounds, boolean
|
|
14
|
+
public RegionChangeEvent(int id, LatLngBounds bounds, boolean isGesture) {
|
|
16
15
|
super(id);
|
|
17
16
|
this.bounds = bounds;
|
|
18
|
-
this.continuous = continuous;
|
|
19
17
|
this.isGesture = isGesture;
|
|
20
18
|
}
|
|
21
19
|
|
|
@@ -32,7 +30,6 @@ public class RegionChangeEvent extends Event<RegionChangeEvent> {
|
|
|
32
30
|
@Override
|
|
33
31
|
public void dispatch(RCTEventEmitter rctEventEmitter) {
|
|
34
32
|
WritableMap event = new WritableNativeMap();
|
|
35
|
-
event.putBoolean("continuous", continuous);
|
|
36
33
|
|
|
37
34
|
WritableMap region = new WritableNativeMap();
|
|
38
35
|
LatLng center = bounds.getCenter();
|
|
@@ -318,7 +318,7 @@ void RNMapsGoogleMapViewEventEmitter::onRegionChangeStart(OnRegionChangeStart $e
|
|
|
318
318
|
region.setProperty(runtime, "longitudeDelta", $event.region.longitudeDelta);
|
|
319
319
|
$payload.setProperty(runtime, "region", region);
|
|
320
320
|
}
|
|
321
|
-
$payload.setProperty(runtime, "
|
|
321
|
+
$payload.setProperty(runtime, "isGesture", $event.isGesture);
|
|
322
322
|
return $payload;
|
|
323
323
|
});
|
|
324
324
|
}
|
|
@@ -335,7 +335,7 @@ void RNMapsGoogleMapViewEventEmitter::onRegionChange(OnRegionChange $event) cons
|
|
|
335
335
|
region.setProperty(runtime, "longitudeDelta", $event.region.longitudeDelta);
|
|
336
336
|
$payload.setProperty(runtime, "region", region);
|
|
337
337
|
}
|
|
338
|
-
$payload.setProperty(runtime, "
|
|
338
|
+
$payload.setProperty(runtime, "isGesture", $event.isGesture);
|
|
339
339
|
return $payload;
|
|
340
340
|
});
|
|
341
341
|
}
|
|
@@ -352,7 +352,7 @@ void RNMapsGoogleMapViewEventEmitter::onRegionChangeComplete(OnRegionChangeCompl
|
|
|
352
352
|
region.setProperty(runtime, "longitudeDelta", $event.region.longitudeDelta);
|
|
353
353
|
$payload.setProperty(runtime, "region", region);
|
|
354
354
|
}
|
|
355
|
-
$payload.setProperty(runtime, "
|
|
355
|
+
$payload.setProperty(runtime, "isGesture", $event.isGesture);
|
|
356
356
|
return $payload;
|
|
357
357
|
});
|
|
358
358
|
}
|
|
@@ -730,7 +730,7 @@ void RNMapsMapViewEventEmitter::onRegionChangeStart(OnRegionChangeStart $event)
|
|
|
730
730
|
region.setProperty(runtime, "longitudeDelta", $event.region.longitudeDelta);
|
|
731
731
|
$payload.setProperty(runtime, "region", region);
|
|
732
732
|
}
|
|
733
|
-
$payload.setProperty(runtime, "
|
|
733
|
+
$payload.setProperty(runtime, "isGesture", $event.isGesture);
|
|
734
734
|
return $payload;
|
|
735
735
|
});
|
|
736
736
|
}
|
|
@@ -747,7 +747,7 @@ void RNMapsMapViewEventEmitter::onRegionChange(OnRegionChange $event) const {
|
|
|
747
747
|
region.setProperty(runtime, "longitudeDelta", $event.region.longitudeDelta);
|
|
748
748
|
$payload.setProperty(runtime, "region", region);
|
|
749
749
|
}
|
|
750
|
-
$payload.setProperty(runtime, "
|
|
750
|
+
$payload.setProperty(runtime, "isGesture", $event.isGesture);
|
|
751
751
|
return $payload;
|
|
752
752
|
});
|
|
753
753
|
}
|
|
@@ -764,7 +764,7 @@ void RNMapsMapViewEventEmitter::onRegionChangeComplete(OnRegionChangeComplete $e
|
|
|
764
764
|
region.setProperty(runtime, "longitudeDelta", $event.region.longitudeDelta);
|
|
765
765
|
$payload.setProperty(runtime, "region", region);
|
|
766
766
|
}
|
|
767
|
-
$payload.setProperty(runtime, "
|
|
767
|
+
$payload.setProperty(runtime, "isGesture", $event.isGesture);
|
|
768
768
|
return $payload;
|
|
769
769
|
});
|
|
770
770
|
}
|
|
@@ -245,7 +245,7 @@ class RNMapsGoogleMapViewEventEmitter : public ViewEventEmitter {
|
|
|
245
245
|
|
|
246
246
|
struct OnRegionChangeStart {
|
|
247
247
|
OnRegionChangeStartRegion region;
|
|
248
|
-
bool
|
|
248
|
+
bool isGesture;
|
|
249
249
|
};
|
|
250
250
|
|
|
251
251
|
struct OnRegionChangeRegion {
|
|
@@ -257,7 +257,7 @@ class RNMapsGoogleMapViewEventEmitter : public ViewEventEmitter {
|
|
|
257
257
|
|
|
258
258
|
struct OnRegionChange {
|
|
259
259
|
OnRegionChangeRegion region;
|
|
260
|
-
bool
|
|
260
|
+
bool isGesture;
|
|
261
261
|
};
|
|
262
262
|
|
|
263
263
|
struct OnRegionChangeCompleteRegion {
|
|
@@ -269,7 +269,7 @@ class RNMapsGoogleMapViewEventEmitter : public ViewEventEmitter {
|
|
|
269
269
|
|
|
270
270
|
struct OnRegionChangeComplete {
|
|
271
271
|
OnRegionChangeCompleteRegion region;
|
|
272
|
-
bool
|
|
272
|
+
bool isGesture;
|
|
273
273
|
};
|
|
274
274
|
|
|
275
275
|
struct OnUserLocationChangeCoordinate {
|
|
@@ -593,7 +593,7 @@ class RNMapsMapViewEventEmitter : public ViewEventEmitter {
|
|
|
593
593
|
|
|
594
594
|
struct OnRegionChangeStart {
|
|
595
595
|
OnRegionChangeStartRegion region;
|
|
596
|
-
bool
|
|
596
|
+
bool isGesture;
|
|
597
597
|
};
|
|
598
598
|
|
|
599
599
|
struct OnRegionChangeRegion {
|
|
@@ -605,7 +605,7 @@ class RNMapsMapViewEventEmitter : public ViewEventEmitter {
|
|
|
605
605
|
|
|
606
606
|
struct OnRegionChange {
|
|
607
607
|
OnRegionChangeRegion region;
|
|
608
|
-
bool
|
|
608
|
+
bool isGesture;
|
|
609
609
|
};
|
|
610
610
|
|
|
611
611
|
struct OnRegionChangeCompleteRegion {
|
|
@@ -617,7 +617,7 @@ class RNMapsMapViewEventEmitter : public ViewEventEmitter {
|
|
|
617
617
|
|
|
618
618
|
struct OnRegionChangeComplete {
|
|
619
619
|
OnRegionChangeCompleteRegion region;
|
|
620
|
-
bool
|
|
620
|
+
bool isGesture;
|
|
621
621
|
};
|
|
622
622
|
|
|
623
623
|
struct OnUserLocationChangeCoordinate {
|
|
@@ -32,7 +32,7 @@ RNMapsCircleProps::RNMapsCircleProps(
|
|
|
32
32
|
fillColor(convertRawProp(context, rawProps, "fillColor", sourceProps.fillColor, {})),
|
|
33
33
|
radius(convertRawProp(context, rawProps, "radius", sourceProps.radius, {0.0})),
|
|
34
34
|
strokeColor(convertRawProp(context, rawProps, "strokeColor", sourceProps.strokeColor, {})),
|
|
35
|
-
strokeWidth(convertRawProp(context, rawProps, "strokeWidth", sourceProps.strokeWidth, {
|
|
35
|
+
strokeWidth(convertRawProp(context, rawProps, "strokeWidth", sourceProps.strokeWidth, {1.0})),
|
|
36
36
|
tappable(convertRawProp(context, rawProps, "tappable", sourceProps.tappable, {false}))
|
|
37
37
|
{}
|
|
38
38
|
RNMapsGoogleMapViewProps::RNMapsGoogleMapViewProps(
|
|
@@ -83,6 +83,7 @@ RNMapsGooglePolygonProps::RNMapsGooglePolygonProps(
|
|
|
83
83
|
coordinates(convertRawProp(context, rawProps, "coordinates", sourceProps.coordinates, {})),
|
|
84
84
|
fillColor(convertRawProp(context, rawProps, "fillColor", sourceProps.fillColor, {})),
|
|
85
85
|
strokeColor(convertRawProp(context, rawProps, "strokeColor", sourceProps.strokeColor, {})),
|
|
86
|
+
strokeWidth(convertRawProp(context, rawProps, "strokeWidth", sourceProps.strokeWidth, {1.0})),
|
|
86
87
|
geodesic(convertRawProp(context, rawProps, "geodesic", sourceProps.geodesic, {false})),
|
|
87
88
|
holes(convertRawProp(context, rawProps, "holes", sourceProps.holes, {})),
|
|
88
89
|
tappable(convertRawProp(context, rawProps, "tappable", sourceProps.tappable, {false}))
|
|
@@ -153,10 +154,12 @@ RNMapsMarkerProps::RNMapsMarkerProps(
|
|
|
153
154
|
image(convertRawProp(context, rawProps, "image", sourceProps.image, {})),
|
|
154
155
|
calloutOffset(convertRawProp(context, rawProps, "calloutOffset", sourceProps.calloutOffset, {})),
|
|
155
156
|
displayPriority(convertRawProp(context, rawProps, "displayPriority", sourceProps.displayPriority, {RNMapsMarkerDisplayPriority::Required})),
|
|
157
|
+
centerOffset(convertRawProp(context, rawProps, "centerOffset", sourceProps.centerOffset, {})),
|
|
156
158
|
coordinate(convertRawProp(context, rawProps, "coordinate", sourceProps.coordinate, {})),
|
|
157
159
|
description(convertRawProp(context, rawProps, "description", sourceProps.description, {})),
|
|
158
160
|
draggable(convertRawProp(context, rawProps, "draggable", sourceProps.draggable, {false})),
|
|
159
161
|
title(convertRawProp(context, rawProps, "title", sourceProps.title, {})),
|
|
162
|
+
tracksViewChanges(convertRawProp(context, rawProps, "tracksViewChanges", sourceProps.tracksViewChanges, {true})),
|
|
160
163
|
identifier(convertRawProp(context, rawProps, "identifier", sourceProps.identifier, {})),
|
|
161
164
|
isPreselected(convertRawProp(context, rawProps, "isPreselected", sourceProps.isPreselected, {false})),
|
|
162
165
|
opacity(convertRawProp(context, rawProps, "opacity", sourceProps.opacity, {1.0})),
|
|
@@ -188,7 +191,7 @@ RNMapsPolylineProps::RNMapsPolylineProps(
|
|
|
188
191
|
lineJoin(convertRawProp(context, rawProps, "lineJoin", sourceProps.lineJoin, {RNMapsPolylineLineJoin::Miter})),
|
|
189
192
|
strokeColor(convertRawProp(context, rawProps, "strokeColor", sourceProps.strokeColor, {})),
|
|
190
193
|
strokeColors(convertRawProp(context, rawProps, "strokeColors", sourceProps.strokeColors, {})),
|
|
191
|
-
strokeWidth(convertRawProp(context, rawProps, "strokeWidth", sourceProps.strokeWidth, {
|
|
194
|
+
strokeWidth(convertRawProp(context, rawProps, "strokeWidth", sourceProps.strokeWidth, {1.0})),
|
|
192
195
|
tappable(convertRawProp(context, rawProps, "tappable", sourceProps.tappable, {false}))
|
|
193
196
|
{}
|
|
194
197
|
RNMapsUrlTileProps::RNMapsUrlTileProps(
|