react-native-maps 1.11.3 → 1.13.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/android/src/main/java/com/rnmaps/maps/MapManager.java +447 -420
- package/android/src/main/java/com/rnmaps/maps/MapMarker.java +4 -0
- package/android/src/main/java/com/rnmaps/maps/MapMarkerManager.java +3 -1
- package/android/src/main/java/com/rnmaps/maps/MapModule.java +1 -27
- package/android/src/main/java/com/rnmaps/maps/MapView.java +72 -44
- package/ios/AirGoogleMaps/AIRGMSMarker.h +2 -0
- package/ios/AirGoogleMaps/AIRGoogleMap.h +2 -1
- package/ios/AirGoogleMaps/AIRGoogleMap.m +41 -10
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +2 -0
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +42 -20
- package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +2 -0
- package/lib/MapMarker.d.ts +2 -2
- package/lib/MapView.d.ts +12 -5
- package/lib/MapView.js +3 -8
- package/lib/decorateMapComponent.d.ts +2 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +1 -2
- package/package.json +1 -1
|
@@ -326,7 +326,9 @@ public class MapMarkerManager extends ViewGroupManager<MapMarker> {
|
|
|
326
326
|
"onCalloutPress", MapBuilder.of("registrationName", "onCalloutPress"),
|
|
327
327
|
"onDragStart", MapBuilder.of("registrationName", "onDragStart"),
|
|
328
328
|
"onDrag", MapBuilder.of("registrationName", "onDrag"),
|
|
329
|
-
"onDragEnd", MapBuilder.of("registrationName", "onDragEnd")
|
|
329
|
+
"onDragEnd", MapBuilder.of("registrationName", "onDragEnd"),
|
|
330
|
+
"onSelect", MapBuilder.of("registrationName", "onSelect"),
|
|
331
|
+
"onDeselect", MapBuilder.of("registrationName", "onDeselect")
|
|
330
332
|
);
|
|
331
333
|
|
|
332
334
|
map.putAll(MapBuilder.of(
|
|
@@ -8,10 +8,8 @@ import android.location.Geocoder;
|
|
|
8
8
|
import android.net.Uri;
|
|
9
9
|
import android.util.Base64;
|
|
10
10
|
import android.util.DisplayMetrics;
|
|
11
|
-
import android.util.Log;
|
|
12
11
|
|
|
13
12
|
import androidx.annotation.Nullable;
|
|
14
|
-
import androidx.annotation.NonNull;
|
|
15
13
|
|
|
16
14
|
import com.facebook.react.bridge.Promise;
|
|
17
15
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
@@ -25,8 +23,6 @@ import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
|
|
25
23
|
import com.facebook.react.uimanager.UIBlock;
|
|
26
24
|
import com.facebook.react.uimanager.UIManagerModule;
|
|
27
25
|
import com.google.android.gms.maps.GoogleMap;
|
|
28
|
-
import com.google.android.gms.maps.MapsInitializer;
|
|
29
|
-
import com.google.android.gms.maps.OnMapsSdkInitializedCallback;
|
|
30
26
|
import com.google.android.gms.maps.model.CameraPosition;
|
|
31
27
|
import com.google.android.gms.maps.model.LatLng;
|
|
32
28
|
|
|
@@ -35,10 +31,9 @@ import java.io.Closeable;
|
|
|
35
31
|
import java.io.File;
|
|
36
32
|
import java.io.FileOutputStream;
|
|
37
33
|
import java.io.IOException;
|
|
38
|
-
|
|
34
|
+
import java.util.HashMap;
|
|
39
35
|
import java.util.List;
|
|
40
36
|
import java.util.Map;
|
|
41
|
-
import java.util.HashMap;
|
|
42
37
|
|
|
43
38
|
@ReactModule(name = MapModule.NAME)
|
|
44
39
|
public class MapModule extends ReactContextBaseJavaModule {
|
|
@@ -356,25 +351,4 @@ public class MapModule extends ReactContextBaseJavaModule {
|
|
|
356
351
|
}
|
|
357
352
|
});
|
|
358
353
|
}
|
|
359
|
-
|
|
360
|
-
@ReactMethod
|
|
361
|
-
public void enableLatestRenderer(final Promise promise) {
|
|
362
|
-
final ReactApplicationContext context = getReactApplicationContext();
|
|
363
|
-
|
|
364
|
-
UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
|
|
365
|
-
uiManager.addUIBlock(new UIBlock()
|
|
366
|
-
{
|
|
367
|
-
@Override
|
|
368
|
-
public void execute(NativeViewHierarchyManager nvhm)
|
|
369
|
-
{
|
|
370
|
-
MapsInitializer.initialize(context, MapsInitializer.Renderer.LATEST, new OnMapsSdkInitializedCallback() {
|
|
371
|
-
@Override
|
|
372
|
-
public void onMapsSdkInitialized(@NonNull MapsInitializer.Renderer renderer) {
|
|
373
|
-
Log.d("AirMapRenderer", renderer.toString());
|
|
374
|
-
promise.resolve(renderer.toString());
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
354
|
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
package com.rnmaps.maps;
|
|
2
2
|
|
|
3
|
+
import static androidx.core.content.PermissionChecker.checkSelfPermission;
|
|
4
|
+
|
|
3
5
|
import android.content.Context;
|
|
4
6
|
import android.content.res.ColorStateList;
|
|
5
7
|
import android.graphics.Bitmap;
|
|
6
8
|
import android.graphics.Color;
|
|
7
9
|
import android.graphics.Point;
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import androidx.annotation.Nullable;
|
|
11
|
-
import androidx.core.content.PermissionChecker;
|
|
12
|
-
import androidx.core.view.GestureDetectorCompat;
|
|
13
|
-
import androidx.core.view.MotionEventCompat;
|
|
10
|
+
import android.location.Location;
|
|
11
|
+
import android.util.Log;
|
|
14
12
|
import android.view.GestureDetector;
|
|
15
13
|
import android.view.MotionEvent;
|
|
16
14
|
import android.view.View;
|
|
@@ -18,8 +16,14 @@ import android.view.ViewGroup;
|
|
|
18
16
|
import android.widget.ImageView;
|
|
19
17
|
import android.widget.ProgressBar;
|
|
20
18
|
import android.widget.RelativeLayout;
|
|
21
|
-
import android.location.Location;
|
|
22
19
|
|
|
20
|
+
import androidx.annotation.NonNull;
|
|
21
|
+
import androidx.annotation.Nullable;
|
|
22
|
+
import androidx.core.content.PermissionChecker;
|
|
23
|
+
import androidx.core.view.GestureDetectorCompat;
|
|
24
|
+
import androidx.core.view.MotionEventCompat;
|
|
25
|
+
|
|
26
|
+
import com.facebook.react.bridge.Arguments;
|
|
23
27
|
import com.facebook.react.bridge.LifecycleEventListener;
|
|
24
28
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
25
29
|
import com.facebook.react.bridge.ReadableArray;
|
|
@@ -28,21 +32,22 @@ import com.facebook.react.bridge.WritableArray;
|
|
|
28
32
|
import com.facebook.react.bridge.WritableMap;
|
|
29
33
|
import com.facebook.react.bridge.WritableNativeArray;
|
|
30
34
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
31
|
-
import com.facebook.react.bridge.Arguments;
|
|
32
35
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
33
36
|
import com.facebook.react.uimanager.UIManagerHelper;
|
|
34
|
-
import com.facebook.react.uimanager.UIManagerModule;
|
|
35
37
|
import com.facebook.react.uimanager.common.UIManagerType;
|
|
36
38
|
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
37
39
|
import com.google.android.gms.maps.CameraUpdate;
|
|
38
40
|
import com.google.android.gms.maps.CameraUpdateFactory;
|
|
39
41
|
import com.google.android.gms.maps.GoogleMap;
|
|
40
42
|
import com.google.android.gms.maps.GoogleMapOptions;
|
|
43
|
+
import com.google.android.gms.maps.MapsInitializer;
|
|
41
44
|
import com.google.android.gms.maps.OnMapReadyCallback;
|
|
42
45
|
import com.google.android.gms.maps.Projection;
|
|
43
46
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
|
44
47
|
import com.google.android.gms.maps.model.CameraPosition;
|
|
45
48
|
import com.google.android.gms.maps.model.GroundOverlay;
|
|
49
|
+
import com.google.android.gms.maps.model.IndoorBuilding;
|
|
50
|
+
import com.google.android.gms.maps.model.IndoorLevel;
|
|
46
51
|
import com.google.android.gms.maps.model.LatLng;
|
|
47
52
|
import com.google.android.gms.maps.model.LatLngBounds;
|
|
48
53
|
import com.google.android.gms.maps.model.MapStyleOptions;
|
|
@@ -52,8 +57,6 @@ import com.google.android.gms.maps.model.PointOfInterest;
|
|
|
52
57
|
import com.google.android.gms.maps.model.Polygon;
|
|
53
58
|
import com.google.android.gms.maps.model.Polyline;
|
|
54
59
|
import com.google.android.gms.maps.model.TileOverlay;
|
|
55
|
-
import com.google.android.gms.maps.model.IndoorBuilding;
|
|
56
|
-
import com.google.android.gms.maps.model.IndoorLevel;
|
|
57
60
|
import com.google.maps.android.collections.CircleManager;
|
|
58
61
|
import com.google.maps.android.collections.GroundOverlayManager;
|
|
59
62
|
import com.google.maps.android.collections.MarkerManager;
|
|
@@ -75,8 +78,6 @@ import java.util.List;
|
|
|
75
78
|
import java.util.Map;
|
|
76
79
|
import java.util.concurrent.ExecutionException;
|
|
77
80
|
|
|
78
|
-
import static androidx.core.content.PermissionChecker.checkSelfPermission;
|
|
79
|
-
|
|
80
81
|
public class MapView extends com.google.android.gms.maps.MapView implements GoogleMap.InfoWindowAdapter,
|
|
81
82
|
GoogleMap.OnMarkerDragListener, OnMapReadyCallback, GoogleMap.OnPoiClickListener, GoogleMap.OnIndoorStateChangeListener {
|
|
82
83
|
public GoogleMap map;
|
|
@@ -104,14 +105,13 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
104
105
|
private boolean moveOnMarkerPress = true;
|
|
105
106
|
private boolean cacheEnabled = false;
|
|
106
107
|
private ReadableMap initialRegion;
|
|
107
|
-
private ReadableMap initialCamera;
|
|
108
108
|
private ReadableMap region;
|
|
109
109
|
private ReadableMap camera;
|
|
110
110
|
private String customMapStyleString;
|
|
111
111
|
private boolean initialRegionSet = false;
|
|
112
|
-
private boolean initialCameraSet = false;
|
|
113
112
|
private LatLngBounds cameraLastIdleBounds;
|
|
114
113
|
private int cameraMoveReason = 0;
|
|
114
|
+
private MapMarker selectedMarker;
|
|
115
115
|
|
|
116
116
|
private static final String[] PERMISSIONS = new String[]{
|
|
117
117
|
"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"};
|
|
@@ -172,9 +172,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
172
172
|
|
|
173
173
|
this.manager = manager;
|
|
174
174
|
this.context = reactContext;
|
|
175
|
-
|
|
175
|
+
MapsInitializer.initialize(context, this.manager.renderer, renderer -> Log.d("AirMapRenderer", renderer.toString()));
|
|
176
176
|
super.onCreate(null);
|
|
177
|
-
// TODO(lmr): what about onStart????
|
|
178
177
|
super.onResume();
|
|
179
178
|
super.getMapAsync(this);
|
|
180
179
|
|
|
@@ -296,6 +295,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
296
295
|
event.putString("id", airMapMarker.getIdentifier());
|
|
297
296
|
manager.pushEvent(context, airMapMarker, "onPress", event);
|
|
298
297
|
|
|
298
|
+
handleMarkerSelection(airMapMarker);
|
|
299
|
+
|
|
299
300
|
// Return false to open the callout info window and center on the marker
|
|
300
301
|
// https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap
|
|
301
302
|
// .OnMarkerClickListener
|
|
@@ -351,6 +352,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
351
352
|
WritableMap event = makeClickEventData(point);
|
|
352
353
|
event.putString("action", "press");
|
|
353
354
|
manager.pushEvent(context, view, "onPress", event);
|
|
355
|
+
|
|
356
|
+
handleMarkerSelection(null);
|
|
354
357
|
}
|
|
355
358
|
});
|
|
356
359
|
|
|
@@ -463,6 +466,40 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
463
466
|
context.addLifecycleEventListener(lifecycleListener);
|
|
464
467
|
}
|
|
465
468
|
|
|
469
|
+
private synchronized void handleMarkerSelection(MapMarker target) {
|
|
470
|
+
if (selectedMarker == target) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
WritableMap event;
|
|
475
|
+
|
|
476
|
+
if (selectedMarker != null) {
|
|
477
|
+
event = makeClickEventData(selectedMarker.getPosition());
|
|
478
|
+
event.putString("action", "marker-deselect");
|
|
479
|
+
event.putString("id", selectedMarker.getIdentifier());
|
|
480
|
+
manager.pushEvent(context, selectedMarker, "onDeselect", event);
|
|
481
|
+
|
|
482
|
+
event = makeClickEventData(selectedMarker.getPosition());
|
|
483
|
+
event.putString("action", "marker-deselect");
|
|
484
|
+
event.putString("id", selectedMarker.getIdentifier());
|
|
485
|
+
manager.pushEvent(context, this, "onMarkerDeselect", event);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if (target != null) {
|
|
489
|
+
event = makeClickEventData(target.getPosition());
|
|
490
|
+
event.putString("action", "marker-select");
|
|
491
|
+
event.putString("id", target.getIdentifier());
|
|
492
|
+
manager.pushEvent(context, target, "onSelect", event);
|
|
493
|
+
|
|
494
|
+
event = makeClickEventData(target.getPosition());
|
|
495
|
+
event.putString("action", "marker-select");
|
|
496
|
+
event.putString("id", target.getIdentifier());
|
|
497
|
+
manager.pushEvent(context, this, "onMarkerSelect", event);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
selectedMarker = target;
|
|
501
|
+
}
|
|
502
|
+
|
|
466
503
|
private boolean hasPermissions() {
|
|
467
504
|
return checkSelfPermission(getContext(), PERMISSIONS[0]) == PermissionChecker.PERMISSION_GRANTED ||
|
|
468
505
|
checkSelfPermission(getContext(), PERMISSIONS[1]) == PermissionChecker.PERMISSION_GRANTED;
|
|
@@ -499,23 +536,10 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
499
536
|
}
|
|
500
537
|
}
|
|
501
538
|
|
|
502
|
-
public void setInitialCamera(ReadableMap initialCamera) {
|
|
503
|
-
this.initialCamera = initialCamera;
|
|
504
|
-
// Theoretically onMapReady might be called before setInitialCamera
|
|
505
|
-
// In that case, trigger moveToCamera manually
|
|
506
|
-
if (!initialCameraSet && map != null) {
|
|
507
|
-
moveToCamera(initialCamera);
|
|
508
|
-
initialCameraSet = true;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
539
|
private void applyBridgedProps() {
|
|
513
540
|
if(initialRegion != null) {
|
|
514
541
|
moveToRegion(initialRegion);
|
|
515
542
|
initialRegionSet = true;
|
|
516
|
-
} else if(initialCamera != null) {
|
|
517
|
-
moveToCamera(initialCamera);
|
|
518
|
-
initialCameraSet = true;
|
|
519
543
|
} else if(region != null) {
|
|
520
544
|
moveToRegion(region);
|
|
521
545
|
} else {
|
|
@@ -563,24 +587,28 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
563
587
|
moveToCamera(camera);
|
|
564
588
|
}
|
|
565
589
|
}
|
|
590
|
+
public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
591
|
+
if (camera == null) return null;
|
|
566
592
|
|
|
567
|
-
|
|
568
|
-
if (camera == null) return;
|
|
569
|
-
|
|
570
|
-
CameraPosition.Builder builder = new CameraPosition.Builder();
|
|
593
|
+
CameraPosition.Builder builder = new CameraPosition.Builder();
|
|
571
594
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
595
|
+
ReadableMap center = camera.getMap("center");
|
|
596
|
+
if (center != null) {
|
|
597
|
+
double lng = center.getDouble("longitude");
|
|
598
|
+
double lat = center.getDouble("latitude");
|
|
599
|
+
builder.target(new LatLng(lat, lng));
|
|
600
|
+
}
|
|
578
601
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
602
|
+
builder.tilt((float)camera.getDouble("pitch"));
|
|
603
|
+
builder.bearing((float)camera.getDouble("heading"));
|
|
604
|
+
builder.zoom((float)camera.getDouble("zoom"));
|
|
582
605
|
|
|
583
|
-
|
|
606
|
+
return builder.build();
|
|
607
|
+
}
|
|
608
|
+
public void moveToCamera(ReadableMap cameraMap) {
|
|
609
|
+
CameraPosition camera = cameraPositionFromMap(cameraMap);
|
|
610
|
+
if (camera == null) return;
|
|
611
|
+
CameraUpdate update = CameraUpdateFactory.newCameraPosition(camera);
|
|
584
612
|
|
|
585
613
|
if (super.getHeight() <= 0 || super.getWidth() <= 0) {
|
|
586
614
|
// in this case, our map has not been laid out yet, so we save the camera update in a
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
@property (nonatomic, strong) NSString *identifier;
|
|
17
17
|
@property (nonatomic, weak) AIRGoogleMapMarker *fakeMarker;
|
|
18
18
|
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
|
|
19
|
+
@property (nonatomic, copy) RCTDirectEventBlock onSelect;
|
|
20
|
+
@property (nonatomic, copy) RCTDirectEventBlock onDeselect;
|
|
19
21
|
@end
|
|
20
22
|
|
|
21
23
|
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
@property (nonatomic, copy) RCTBubblingEventBlock onPanDrag;
|
|
35
35
|
@property (nonatomic, copy) RCTBubblingEventBlock onUserLocationChange;
|
|
36
36
|
@property (nonatomic, copy) RCTBubblingEventBlock onMarkerPress;
|
|
37
|
+
@property (nonatomic, copy) RCTBubblingEventBlock onMarkerSelect;
|
|
38
|
+
@property (nonatomic, copy) RCTBubblingEventBlock onMarkerDeselect;
|
|
37
39
|
@property (nonatomic, copy) RCTBubblingEventBlock onChange;
|
|
38
40
|
@property (nonatomic, copy) RCTBubblingEventBlock onPoiClick;
|
|
39
41
|
@property (nonatomic, copy) RCTDirectEventBlock onRegionChange;
|
|
@@ -80,7 +82,6 @@
|
|
|
80
82
|
|
|
81
83
|
- (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible;
|
|
82
84
|
- (instancetype) initWithMapId:(NSString *) mapId;
|
|
83
|
-
|
|
84
85
|
@end
|
|
85
86
|
|
|
86
87
|
#endif
|
|
@@ -354,6 +354,7 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
354
354
|
|
|
355
355
|
// TODO: not sure why this is necessary
|
|
356
356
|
[self setSelectedMarker:marker];
|
|
357
|
+
|
|
357
358
|
return NO;
|
|
358
359
|
}
|
|
359
360
|
|
|
@@ -582,6 +583,33 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
582
583
|
return self.settings.indoorPicker;
|
|
583
584
|
}
|
|
584
585
|
|
|
586
|
+
-(void)setSelectedMarker:(AIRGMSMarker *)selectedMarker {
|
|
587
|
+
if (selectedMarker == self.selectedMarker) {
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
AIRGMSMarker *airMarker = (AIRGMSMarker *) self.selectedMarker;
|
|
591
|
+
AIRGoogleMapMarker *fakeAirMarker = (AIRGoogleMapMarker *) airMarker.fakeMarker;
|
|
592
|
+
AIRGoogleMapMarker *fakeSelectedMarker = (AIRGoogleMapMarker *) selectedMarker.fakeMarker;
|
|
593
|
+
|
|
594
|
+
if (airMarker && airMarker.onDeselect) {
|
|
595
|
+
airMarker.onDeselect([fakeAirMarker makeEventData:@"marker-deselect"]);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
if (airMarker && self.onMarkerDeselect) {
|
|
599
|
+
self.onMarkerDeselect([fakeAirMarker makeEventData:@"marker-deselect"]);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (selectedMarker && selectedMarker.onSelect) {
|
|
603
|
+
selectedMarker.onSelect([fakeSelectedMarker makeEventData:@"marker-select"]);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
if (selectedMarker && self.onMarkerSelect) {
|
|
607
|
+
self.onMarkerSelect([fakeSelectedMarker makeEventData:@"marker-select"]);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
[super setSelectedMarker:selectedMarker];
|
|
611
|
+
}
|
|
612
|
+
|
|
585
613
|
+ (MKCoordinateRegion) makeGMSCameraPositionFromMap:(GMSMapView *)map andGMSCameraPosition:(GMSCameraPosition *)position {
|
|
586
614
|
// solution from here: http://stackoverflow.com/a/16587735/1102215
|
|
587
615
|
GMSVisibleRegion visibleRegion = map.projection.visibleRegion;
|
|
@@ -740,16 +768,19 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
740
768
|
BOOL isTap = [gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]] || [gestureRecognizer isMemberOfClass:[UITapGestureRecognizer class]];
|
|
741
769
|
if (isTap) {
|
|
742
770
|
BOOL isTapInsideBubble = NO;
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
tapTouch
|
|
771
|
+
CGPoint tapPoint = CGPointZero;
|
|
772
|
+
CGPoint tapPointInBubble = CGPointZero;
|
|
773
|
+
|
|
774
|
+
NSArray* touches = [gestureRecognizer valueForKey:@"touches"];
|
|
775
|
+
UITouch* oneTouch = [touches firstObject];
|
|
776
|
+
NSArray* delayedTouches = [gestureRecognizer valueForKey:@"delayedTouches"];
|
|
777
|
+
NSObject* delayedTouch = [delayedTouches firstObject]; //UIGestureDeleayedTouch
|
|
778
|
+
UITouch* tapTouch = [delayedTouch valueForKey:@"stateWhenDelayed"];
|
|
779
|
+
|
|
780
|
+
if (!tapTouch) {
|
|
781
|
+
tapTouch = oneTouch;
|
|
782
|
+
};
|
|
783
|
+
|
|
753
784
|
tapPoint = [tapTouch locationInView:self];
|
|
754
785
|
isTapInsideBubble = tapTouch != nil && CGRectContainsPoint(bubbleFrame, tapPoint);
|
|
755
786
|
if (isTapInsideBubble) {
|
|
@@ -101,6 +101,8 @@ RCT_EXPORT_VIEW_PROPERTY(onPanDrag, RCTBubblingEventBlock)
|
|
|
101
101
|
RCT_EXPORT_VIEW_PROPERTY(onUserLocationChange, RCTBubblingEventBlock)
|
|
102
102
|
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
|
|
103
103
|
RCT_EXPORT_VIEW_PROPERTY(onMarkerPress, RCTDirectEventBlock)
|
|
104
|
+
RCT_EXPORT_VIEW_PROPERTY(onMarkerSelect, RCTDirectEventBlock)
|
|
105
|
+
RCT_EXPORT_VIEW_PROPERTY(onMarkerDeselect, RCTDirectEventBlock)
|
|
104
106
|
RCT_EXPORT_VIEW_PROPERTY(onRegionChange, RCTDirectEventBlock)
|
|
105
107
|
RCT_EXPORT_VIEW_PROPERTY(onRegionChangeComplete, RCTDirectEventBlock)
|
|
106
108
|
RCT_EXPORT_VIEW_PROPERTY(onPoiClick, RCTDirectEventBlock)
|
|
@@ -24,7 +24,6 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
@interface AIRGoogleMapMarker ()
|
|
27
|
-
- (id)eventFromMarker:(AIRGMSMarker*)marker;
|
|
28
27
|
@end
|
|
29
28
|
|
|
30
29
|
@implementation AIRGoogleMapMarker {
|
|
@@ -60,23 +59,7 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
60
59
|
[_iconView setFrame:CGRectMake(0, 0, width, height)];
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
- (id)eventFromMarker:(AIRGMSMarker*)marker {
|
|
64
62
|
|
|
65
|
-
CLLocationCoordinate2D coordinate = marker.position;
|
|
66
|
-
CGPoint position = [self.realMarker.map.projection pointForCoordinate:coordinate];
|
|
67
|
-
|
|
68
|
-
return @{
|
|
69
|
-
@"id": marker.identifier ?: @"unknown",
|
|
70
|
-
@"position": @{
|
|
71
|
-
@"x": @(position.x),
|
|
72
|
-
@"y": @(position.y),
|
|
73
|
-
},
|
|
74
|
-
@"coordinate": @{
|
|
75
|
-
@"latitude": @(coordinate.latitude),
|
|
76
|
-
@"longitude": @(coordinate.longitude),
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
63
|
|
|
81
64
|
- (void)iconViewInsertSubview:(UIView*)subview atIndex:(NSInteger)atIndex {
|
|
82
65
|
if (!_realMarker.iconView) {
|
|
@@ -199,17 +182,17 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
199
182
|
|
|
200
183
|
- (void)didBeginDraggingMarker:(AIRGMSMarker *)marker {
|
|
201
184
|
if (!self.onDragStart) return;
|
|
202
|
-
self.onDragStart([self
|
|
185
|
+
self.onDragStart([self makeEventData]);
|
|
203
186
|
}
|
|
204
187
|
|
|
205
188
|
- (void)didEndDraggingMarker:(AIRGMSMarker *)marker {
|
|
206
189
|
if (!self.onDragEnd) return;
|
|
207
|
-
self.onDragEnd([self
|
|
190
|
+
self.onDragEnd([self makeEventData]);
|
|
208
191
|
}
|
|
209
192
|
|
|
210
193
|
- (void)didDragMarker:(AIRGMSMarker *)marker {
|
|
211
194
|
if (!self.onDrag) return;
|
|
212
|
-
self.onDrag([self
|
|
195
|
+
self.onDrag([self makeEventData]);
|
|
213
196
|
}
|
|
214
197
|
|
|
215
198
|
- (void)setCoordinate:(CLLocationCoordinate2D)coordinate {
|
|
@@ -244,6 +227,22 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
244
227
|
return _realMarker.onPress;
|
|
245
228
|
}
|
|
246
229
|
|
|
230
|
+
- (void)setOnSelect:(RCTDirectEventBlock)onSelect {
|
|
231
|
+
_realMarker.onSelect = onSelect;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
- (RCTDirectEventBlock)onSelect {
|
|
235
|
+
return _realMarker.onSelect;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
- (void)setOnDeselect:(RCTDirectEventBlock)onDeselect {
|
|
239
|
+
_realMarker.onDeselect = onDeselect;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
- (RCTDirectEventBlock)onDeselect {
|
|
243
|
+
return _realMarker.onDeselect;
|
|
244
|
+
}
|
|
245
|
+
|
|
247
246
|
- (void)setOpacity:(double)opacity
|
|
248
247
|
{
|
|
249
248
|
_realMarker.opacity = opacity;
|
|
@@ -429,6 +428,29 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
429
428
|
return _realMarker.tracksInfoWindowChanges;
|
|
430
429
|
}
|
|
431
430
|
|
|
431
|
+
|
|
432
|
+
- (id)makeEventData:(NSString *)action {
|
|
433
|
+
CLLocationCoordinate2D coordinate = self.realMarker.position;
|
|
434
|
+
CGPoint position = [self.realMarker.map.projection pointForCoordinate:coordinate];
|
|
435
|
+
|
|
436
|
+
return @{
|
|
437
|
+
@"id": self.identifier ?: @"unknown",
|
|
438
|
+
@"position": @{
|
|
439
|
+
@"x": @(position.x),
|
|
440
|
+
@"y": @(position.y),
|
|
441
|
+
},
|
|
442
|
+
@"coordinate": @{
|
|
443
|
+
@"latitude": @(coordinate.latitude),
|
|
444
|
+
@"longitude": @(coordinate.longitude),
|
|
445
|
+
},
|
|
446
|
+
@"action": action,
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
- (id)makeEventData {
|
|
451
|
+
return [self makeEventData:@"unknown"];
|
|
452
|
+
}
|
|
453
|
+
|
|
432
454
|
@end
|
|
433
455
|
|
|
434
456
|
#endif
|
|
@@ -52,6 +52,8 @@ RCT_EXPORT_VIEW_PROPERTY(opacity, double)
|
|
|
52
52
|
RCT_EXPORT_VIEW_PROPERTY(onDragStart, RCTDirectEventBlock)
|
|
53
53
|
RCT_EXPORT_VIEW_PROPERTY(onDrag, RCTDirectEventBlock)
|
|
54
54
|
RCT_EXPORT_VIEW_PROPERTY(onDragEnd, RCTDirectEventBlock)
|
|
55
|
+
RCT_EXPORT_VIEW_PROPERTY(onSelect, RCTDirectEventBlock)
|
|
56
|
+
RCT_EXPORT_VIEW_PROPERTY(onDeselect, RCTDirectEventBlock)
|
|
55
57
|
|
|
56
58
|
RCT_EXPORT_METHOD(showCallout:(nonnull NSNumber *)reactTag)
|
|
57
59
|
{
|
package/lib/MapMarker.d.ts
CHANGED
|
@@ -168,8 +168,8 @@ export type MapMarkerProps = ViewProps & {
|
|
|
168
168
|
* Callback that is called when the marker becomes selected.
|
|
169
169
|
* This will be called when the callout for that marker is about to be shown.
|
|
170
170
|
*
|
|
171
|
-
* @platform iOS:
|
|
172
|
-
* @platform Android:
|
|
171
|
+
* @platform iOS: Supported.
|
|
172
|
+
* @platform Android: Supported
|
|
173
173
|
*/
|
|
174
174
|
onSelect?: (event: MarkerSelectEvent) => void;
|
|
175
175
|
/**
|
package/lib/MapView.d.ts
CHANGED
|
@@ -101,6 +101,14 @@ export type MapViewProps = ViewProps & {
|
|
|
101
101
|
* google cloud mapId to enable cloud styling and more
|
|
102
102
|
*/
|
|
103
103
|
googleMapId?: string;
|
|
104
|
+
/**
|
|
105
|
+
* https://developers.google.com/maps/documentation/android-sdk/renderer
|
|
106
|
+
* google maps renderer
|
|
107
|
+
* @default `LATEST`
|
|
108
|
+
* @platform iOS: Not supported
|
|
109
|
+
* @platform Android: Supported
|
|
110
|
+
*/
|
|
111
|
+
googleRenderer?: 'LATEST' | 'LEGACY';
|
|
104
112
|
/**
|
|
105
113
|
* Sets loading background color.
|
|
106
114
|
*
|
|
@@ -243,8 +251,8 @@ export type MapViewProps = ViewProps & {
|
|
|
243
251
|
* Callback that is called when a marker on the map becomes deselected.
|
|
244
252
|
* This will be called when the callout for that marker is about to be hidden.
|
|
245
253
|
*
|
|
246
|
-
* @platform iOS:
|
|
247
|
-
* @platform Android:
|
|
254
|
+
* @platform iOS: Supported
|
|
255
|
+
* @platform Android: Supported
|
|
248
256
|
*/
|
|
249
257
|
onMarkerDeselect?: (event: MarkerDeselectEvent) => void;
|
|
250
258
|
/**
|
|
@@ -280,8 +288,8 @@ export type MapViewProps = ViewProps & {
|
|
|
280
288
|
* Callback that is called when a marker on the map becomes selected.
|
|
281
289
|
* This will be called when the callout for that marker is about to be shown.
|
|
282
290
|
*
|
|
283
|
-
* @platform iOS:
|
|
284
|
-
* @platform Android:
|
|
291
|
+
* @platform iOS: Supported.
|
|
292
|
+
* @platform Android: Supported
|
|
285
293
|
*/
|
|
286
294
|
onMarkerSelect?: (event: MarkerSelectEvent) => void;
|
|
287
295
|
/**
|
|
@@ -682,5 +690,4 @@ declare class MapView extends React.Component<MapViewProps, State> {
|
|
|
682
690
|
render(): React.JSX.Element;
|
|
683
691
|
}
|
|
684
692
|
export declare const AnimatedMapView: RNAnimated.AnimatedComponent<typeof MapView>;
|
|
685
|
-
export declare const enableLatestRenderer: () => any;
|
|
686
693
|
export default MapView;
|
package/lib/MapView.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.AnimatedMapView = exports.MAP_TYPES = void 0;
|
|
27
27
|
const React = __importStar(require("react"));
|
|
28
28
|
const react_native_1 = require("react-native");
|
|
29
29
|
const decorateMapComponent_1 = require("./decorateMapComponent");
|
|
@@ -308,6 +308,7 @@ class MapView extends React.Component {
|
|
|
308
308
|
onMapReady: this._onMapReady,
|
|
309
309
|
liteMode: this.props.liteMode,
|
|
310
310
|
googleMapId: this.props.googleMapId,
|
|
311
|
+
googleRenderer: this.props.googleRenderer,
|
|
311
312
|
ref: this.map,
|
|
312
313
|
customMapStyleString: this.props.customMapStyle
|
|
313
314
|
? JSON.stringify(this.props.customMapStyle)
|
|
@@ -330,6 +331,7 @@ class MapView extends React.Component {
|
|
|
330
331
|
region: null,
|
|
331
332
|
liteMode: this.props.liteMode,
|
|
332
333
|
googleMapId: this.props.googleMapId,
|
|
334
|
+
googleRenderer: this.props.googleRenderer,
|
|
333
335
|
initialRegion: this.props.initialRegion || null,
|
|
334
336
|
initialCamera: this.props.initialCamera,
|
|
335
337
|
ref: this.map,
|
|
@@ -361,12 +363,5 @@ else {
|
|
|
361
363
|
}
|
|
362
364
|
const getNativeMapComponent = (provider) => airMaps[provider || 'default'];
|
|
363
365
|
exports.AnimatedMapView = react_native_1.Animated.createAnimatedComponent(MapView);
|
|
364
|
-
const enableLatestRenderer = () => {
|
|
365
|
-
if (react_native_1.Platform.OS !== 'android') {
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
return react_native_1.NativeModules.AirMapModule.enableLatestRenderer();
|
|
369
|
-
};
|
|
370
|
-
exports.enableLatestRenderer = enableLatestRenderer;
|
|
371
366
|
MapView.Animated = exports.AnimatedMapView;
|
|
372
367
|
exports.default = MapView;
|
|
@@ -12,6 +12,7 @@ import { MapPolygon } from './MapPolygon';
|
|
|
12
12
|
import { MapPolyline } from './MapPolyline';
|
|
13
13
|
import { MapUrlTile } from './MapUrlTile';
|
|
14
14
|
import { MapWMSTile } from './MapWMSTile';
|
|
15
|
+
import { Commands } from './MapViewNativeComponent';
|
|
15
16
|
export declare const SUPPORTED: ImplementationStatus;
|
|
16
17
|
export declare const USES_DEFAULT_IMPLEMENTATION: ImplementationStatus;
|
|
17
18
|
export declare const NOT_SUPPORTED: ImplementationStatus;
|
|
@@ -28,7 +29,7 @@ type Providers = {
|
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
31
|
export type UIManagerCommand = number;
|
|
31
|
-
export type MapManagerCommand =
|
|
32
|
+
export type MapManagerCommand = keyof typeof Commands;
|
|
32
33
|
export type NativeComponent<H = unknown> = HostComponent<H> | ReturnType<typeof createNotSupportedComponent>;
|
|
33
34
|
type Component = typeof MapCallout | typeof MapCalloutSubview | typeof MapCircle | typeof MapHeatmap | typeof MapLocalTile | typeof MapMarker | typeof MapOverlay | typeof MapPolygon | typeof MapPolyline | typeof MapUrlTile | typeof MapWMSTile;
|
|
34
35
|
type ComponentName = 'Callout' | 'CalloutSubview' | 'Circle' | 'Heatmap' | 'LocalTile' | 'Marker' | 'Overlay' | 'Polygon' | 'Polyline' | 'UrlTile' | 'WMSTile';
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import MapView, { AnimatedMapView as Animated, MAP_TYPES,
|
|
1
|
+
import MapView, { AnimatedMapView as Animated, MAP_TYPES, MapViewProps } from './MapView';
|
|
2
2
|
import Marker from './MapMarker';
|
|
3
3
|
export { MapMarker } from './MapMarker';
|
|
4
4
|
export type { MapMarkerProps } from './MapMarker';
|
|
@@ -28,7 +28,7 @@ export { default as Geojson } from './Geojson';
|
|
|
28
28
|
export type { GeojsonProps } from './Geojson';
|
|
29
29
|
export { Marker, Overlay };
|
|
30
30
|
export type { MapViewProps };
|
|
31
|
-
export { Animated, MAP_TYPES
|
|
31
|
+
export { Animated, MAP_TYPES };
|
|
32
32
|
export * from './ProviderConstants';
|
|
33
33
|
export * from './MapView.types';
|
|
34
34
|
export * from './MapPolygon.types';
|