react-native-maps 2.0.0-beta.13 → 2.0.0-beta.15
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 +0 -17
- package/android/src/main/java/com/rnmaps/maps/MapView.java +0 -98
- package/ios/Maps/RNMMap.h +23 -31
- package/ios/Maps/RNMMap.m +13 -76
- package/ios/Maps/RNMMapManager.m +19 -4
- package/lib/MapView.d.ts +0 -24
- package/package.json +1 -1
|
@@ -2,12 +2,10 @@ package com.rnmaps.maps;
|
|
|
2
2
|
|
|
3
3
|
import android.view.View;
|
|
4
4
|
|
|
5
|
-
import androidx.annotation.NonNull;
|
|
6
5
|
import androidx.annotation.Nullable;
|
|
7
6
|
|
|
8
7
|
import com.facebook.react.bridge.Arguments;
|
|
9
8
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
11
9
|
import com.facebook.react.bridge.ReadableMap;
|
|
12
10
|
import com.facebook.react.bridge.WritableMap;
|
|
13
11
|
import com.facebook.react.common.MapBuilder;
|
|
@@ -232,26 +230,11 @@ public class MapManager extends ViewGroupManager<MapView> {
|
|
|
232
230
|
view.setCacheEnabled(cacheEnabled);
|
|
233
231
|
}
|
|
234
232
|
|
|
235
|
-
@ReactProp(name = "loadingEnabled", defaultBoolean = false)
|
|
236
|
-
public void setLoadingEnabled(MapView view, boolean loadingEnabled) {
|
|
237
|
-
view.enableMapLoading(loadingEnabled);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
233
|
@ReactProp(name = "moveOnMarkerPress", defaultBoolean = true)
|
|
241
234
|
public void setMoveOnMarkerPress(MapView view, boolean moveOnPress) {
|
|
242
235
|
view.setMoveOnMarkerPress(moveOnPress);
|
|
243
236
|
}
|
|
244
237
|
|
|
245
|
-
@ReactProp(name = "loadingBackgroundColor", customType = "Color")
|
|
246
|
-
public void setLoadingBackgroundColor(MapView view, @Nullable Integer loadingBackgroundColor) {
|
|
247
|
-
view.setLoadingBackgroundColor(loadingBackgroundColor);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
@ReactProp(name = "loadingIndicatorColor", customType = "Color")
|
|
251
|
-
public void setLoadingIndicatorColor(MapView view, @Nullable Integer loadingIndicatorColor) {
|
|
252
|
-
view.setLoadingIndicatorColor(loadingIndicatorColor);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
238
|
@ReactProp(name = "pitchEnabled", defaultBoolean = false)
|
|
256
239
|
public void setPitchEnabled(MapView view, boolean pitchEnabled) {
|
|
257
240
|
view.map.getUiSettings().setTiltGesturesEnabled(pitchEnabled);
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
package com.rnmaps.maps;
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
|
-
import android.content.res.ColorStateList;
|
|
5
4
|
import android.graphics.Bitmap;
|
|
6
|
-
import android.graphics.Color;
|
|
7
5
|
import android.graphics.Point;
|
|
8
6
|
|
|
9
7
|
import androidx.annotation.NonNull;
|
|
@@ -16,13 +14,10 @@ import android.view.MotionEvent;
|
|
|
16
14
|
import android.view.View;
|
|
17
15
|
import android.view.ViewGroup;
|
|
18
16
|
import android.widget.ImageView;
|
|
19
|
-
import android.widget.ProgressBar;
|
|
20
|
-
import android.widget.RelativeLayout;
|
|
21
17
|
import android.location.Location;
|
|
22
18
|
|
|
23
19
|
import com.facebook.react.bridge.LifecycleEventListener;
|
|
24
20
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
25
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
26
21
|
import com.facebook.react.bridge.ReadableMap;
|
|
27
22
|
import com.facebook.react.bridge.WritableArray;
|
|
28
23
|
import com.facebook.react.bridge.WritableMap;
|
|
@@ -67,7 +62,6 @@ import org.xmlpull.v1.XmlPullParserException;
|
|
|
67
62
|
import java.io.IOException;
|
|
68
63
|
import java.io.InputStream;
|
|
69
64
|
import java.util.ArrayList;
|
|
70
|
-
import java.util.Arrays;
|
|
71
65
|
import java.util.HashMap;
|
|
72
66
|
import java.util.List;
|
|
73
67
|
import java.util.Map;
|
|
@@ -87,13 +81,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
87
81
|
private CircleManager.Collection circleCollection;
|
|
88
82
|
private GroundOverlayManager groundOverlayManager;
|
|
89
83
|
private GroundOverlayManager.Collection groundOverlayCollection;
|
|
90
|
-
private ProgressBar mapLoadingProgressBar;
|
|
91
|
-
private RelativeLayout mapLoadingLayout;
|
|
92
84
|
private ImageView cacheImageView;
|
|
93
85
|
private Boolean isMapLoaded = false;
|
|
94
|
-
private Integer loadingBackgroundColor = null;
|
|
95
|
-
private Integer loadingIndicatorColor = null;
|
|
96
|
-
public final int baseMapPadding = 50;
|
|
97
86
|
|
|
98
87
|
private LatLngBounds boundsToMove;
|
|
99
88
|
private CameraUpdate cameraToSet;
|
|
@@ -665,46 +654,10 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
665
654
|
this.cacheView();
|
|
666
655
|
}
|
|
667
656
|
|
|
668
|
-
public void enableMapLoading(boolean loadingEnabled) {
|
|
669
|
-
if (loadingEnabled && !this.isMapLoaded) {
|
|
670
|
-
this.getMapLoadingLayoutView().setVisibility(View.VISIBLE);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
|
|
674
657
|
public void setMoveOnMarkerPress(boolean moveOnPress) {
|
|
675
658
|
this.moveOnMarkerPress = moveOnPress;
|
|
676
659
|
}
|
|
677
660
|
|
|
678
|
-
public void setLoadingBackgroundColor(Integer loadingBackgroundColor) {
|
|
679
|
-
this.loadingBackgroundColor = loadingBackgroundColor;
|
|
680
|
-
|
|
681
|
-
if (this.mapLoadingLayout != null) {
|
|
682
|
-
if (loadingBackgroundColor == null) {
|
|
683
|
-
this.mapLoadingLayout.setBackgroundColor(Color.WHITE);
|
|
684
|
-
} else {
|
|
685
|
-
this.mapLoadingLayout.setBackgroundColor(this.loadingBackgroundColor);
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
public void setLoadingIndicatorColor(Integer loadingIndicatorColor) {
|
|
691
|
-
this.loadingIndicatorColor = loadingIndicatorColor;
|
|
692
|
-
if (this.mapLoadingProgressBar != null) {
|
|
693
|
-
Integer color = loadingIndicatorColor;
|
|
694
|
-
if (color == null) {
|
|
695
|
-
color = Color.parseColor("#606060");
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
ColorStateList progressTintList = ColorStateList.valueOf(loadingIndicatorColor);
|
|
699
|
-
ColorStateList secondaryProgressTintList = ColorStateList.valueOf(loadingIndicatorColor);
|
|
700
|
-
ColorStateList indeterminateTintList = ColorStateList.valueOf(loadingIndicatorColor);
|
|
701
|
-
|
|
702
|
-
this.mapLoadingProgressBar.setProgressTintList(progressTintList);
|
|
703
|
-
this.mapLoadingProgressBar.setSecondaryProgressTintList(secondaryProgressTintList);
|
|
704
|
-
this.mapLoadingProgressBar.setIndeterminateTintList(indeterminateTintList);
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
|
|
708
661
|
public void setHandlePanDrag(boolean handlePanDrag) {
|
|
709
662
|
this.handlePanDrag = handlePanDrag;
|
|
710
663
|
}
|
|
@@ -1008,36 +961,6 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
1008
961
|
manager.pushEvent(context, this, "onPoiClick", event);
|
|
1009
962
|
}
|
|
1010
963
|
|
|
1011
|
-
private ProgressBar getMapLoadingProgressBar() {
|
|
1012
|
-
if (this.mapLoadingProgressBar == null) {
|
|
1013
|
-
this.mapLoadingProgressBar = new ProgressBar(getContext());
|
|
1014
|
-
this.mapLoadingProgressBar.setIndeterminate(true);
|
|
1015
|
-
}
|
|
1016
|
-
if (this.loadingIndicatorColor != null) {
|
|
1017
|
-
this.setLoadingIndicatorColor(this.loadingIndicatorColor);
|
|
1018
|
-
}
|
|
1019
|
-
return this.mapLoadingProgressBar;
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
private RelativeLayout getMapLoadingLayoutView() {
|
|
1023
|
-
if (this.mapLoadingLayout == null) {
|
|
1024
|
-
this.mapLoadingLayout = new RelativeLayout(getContext());
|
|
1025
|
-
this.mapLoadingLayout.setBackgroundColor(Color.LTGRAY);
|
|
1026
|
-
this.addView(this.mapLoadingLayout,
|
|
1027
|
-
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
|
1028
|
-
ViewGroup.LayoutParams.MATCH_PARENT));
|
|
1029
|
-
|
|
1030
|
-
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
|
|
1031
|
-
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
|
1032
|
-
params.addRule(RelativeLayout.CENTER_IN_PARENT);
|
|
1033
|
-
this.mapLoadingLayout.addView(this.getMapLoadingProgressBar(), params);
|
|
1034
|
-
|
|
1035
|
-
this.mapLoadingLayout.setVisibility(View.INVISIBLE);
|
|
1036
|
-
}
|
|
1037
|
-
this.setLoadingBackgroundColor(this.loadingBackgroundColor);
|
|
1038
|
-
return this.mapLoadingLayout;
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
964
|
private ImageView getCacheImageView() {
|
|
1042
965
|
if (this.cacheImageView == null) {
|
|
1043
966
|
this.cacheImageView = new ImageView(getContext());
|
|
@@ -1056,41 +979,20 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
1056
979
|
}
|
|
1057
980
|
}
|
|
1058
981
|
|
|
1059
|
-
private void removeMapLoadingProgressBar() {
|
|
1060
|
-
if (this.mapLoadingProgressBar != null) {
|
|
1061
|
-
((ViewGroup) this.mapLoadingProgressBar.getParent()).removeView(this.mapLoadingProgressBar);
|
|
1062
|
-
this.mapLoadingProgressBar = null;
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
private void removeMapLoadingLayoutView() {
|
|
1067
|
-
this.removeMapLoadingProgressBar();
|
|
1068
|
-
if (this.mapLoadingLayout != null) {
|
|
1069
|
-
((ViewGroup) this.mapLoadingLayout.getParent()).removeView(this.mapLoadingLayout);
|
|
1070
|
-
this.mapLoadingLayout = null;
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
982
|
private void cacheView() {
|
|
1075
983
|
if (this.cacheEnabled) {
|
|
1076
984
|
final ImageView cacheImageView = this.getCacheImageView();
|
|
1077
|
-
final RelativeLayout mapLoadingLayout = this.getMapLoadingLayoutView();
|
|
1078
985
|
cacheImageView.setVisibility(View.INVISIBLE);
|
|
1079
|
-
mapLoadingLayout.setVisibility(View.VISIBLE);
|
|
1080
986
|
if (this.isMapLoaded) {
|
|
1081
987
|
this.map.snapshot(new GoogleMap.SnapshotReadyCallback() {
|
|
1082
988
|
@Override public void onSnapshotReady(Bitmap bitmap) {
|
|
1083
989
|
cacheImageView.setImageBitmap(bitmap);
|
|
1084
990
|
cacheImageView.setVisibility(View.VISIBLE);
|
|
1085
|
-
mapLoadingLayout.setVisibility(View.INVISIBLE);
|
|
1086
991
|
}
|
|
1087
992
|
});
|
|
1088
993
|
}
|
|
1089
994
|
} else {
|
|
1090
995
|
this.removeCacheImageView();
|
|
1091
|
-
if (this.isMapLoaded) {
|
|
1092
|
-
this.removeMapLoadingLayoutView();
|
|
1093
|
-
}
|
|
1094
996
|
}
|
|
1095
997
|
}
|
|
1096
998
|
|
package/ios/Maps/RNMMap.h
CHANGED
|
@@ -23,54 +23,46 @@ extern const NSInteger RNMMapMaxZoomLevel;
|
|
|
23
23
|
|
|
24
24
|
@interface RNMMap: MKMapView<SMCalloutViewDelegate>
|
|
25
25
|
|
|
26
|
-
@property (nonatomic,
|
|
27
|
-
@property (nonatomic, strong) UIImageView *cacheImageView;
|
|
28
|
-
@property (nonatomic, strong) UIView *loadingView;
|
|
29
|
-
|
|
30
|
-
@property (nonatomic, copy) NSString *userLocationAnnotationTitle;
|
|
26
|
+
@property (nonatomic, assign) BOOL cacheEnabled;
|
|
31
27
|
@property (nonatomic, assign) BOOL followUserLocation;
|
|
32
|
-
@property (nonatomic, assign) BOOL userLocationCalloutEnabled;
|
|
33
28
|
@property (nonatomic, assign) BOOL hasStartedRendering;
|
|
34
|
-
@property (nonatomic, assign) BOOL
|
|
35
|
-
@property (nonatomic, assign) BOOL
|
|
36
|
-
@property (nonatomic,
|
|
37
|
-
@property (nonatomic,
|
|
38
|
-
@property (nonatomic, assign) BOOL hasShownInitialLoading;
|
|
39
|
-
@property (nonatomic, assign) CGFloat minDelta;
|
|
29
|
+
@property (nonatomic, assign) BOOL ignoreRegionChanges;
|
|
30
|
+
@property (nonatomic, assign) BOOL mapLoaded;
|
|
31
|
+
@property (nonatomic, assign) BOOL userLocationCalloutEnabled;
|
|
32
|
+
@property (nonatomic, assign) BOOL mapChangedFromUserInteraction;
|
|
40
33
|
@property (nonatomic, assign) CGFloat maxDelta;
|
|
41
|
-
@property (nonatomic, assign) UIEdgeInsets legalLabelInsets;
|
|
42
|
-
@property (nonatomic, assign) MKCoordinateRegion initialRegion;
|
|
43
|
-
@property (nonatomic, assign) MKMapCamera *initialCamera;
|
|
44
|
-
@property (nonatomic, assign) CGFloat minZoomLevel;
|
|
45
34
|
@property (nonatomic, assign) CGFloat maxZoomLevel;
|
|
35
|
+
@property (nonatomic, assign) CGFloat minDelta;
|
|
36
|
+
@property (nonatomic, assign) CGFloat minZoomLevel;
|
|
46
37
|
@property (nonatomic, assign) CGPoint compassOffset;
|
|
47
|
-
@property (nonatomic, assign) UIEdgeInsets mapPadding;
|
|
48
|
-
|
|
49
38
|
@property (nonatomic, assign) CLLocationCoordinate2D pendingCenter;
|
|
39
|
+
@property (nonatomic, assign) MKCoordinateRegion initialRegion;
|
|
50
40
|
@property (nonatomic, assign) MKCoordinateSpan pendingSpan;
|
|
41
|
+
@property (nonatomic, assign) MKMapCamera *initialCamera;
|
|
42
|
+
@property (nonatomic, assign) UIEdgeInsets legalLabelInsets;
|
|
43
|
+
@property (nonatomic, assign) UIEdgeInsets mapPadding;
|
|
44
|
+
@property (nonatomic, copy) NSString *userLocationAnnotationTitle;
|
|
45
|
+
@property (nonatomic, strong) SMCalloutView *calloutView;
|
|
46
|
+
@property (nonatomic, strong) UIImageView *cacheImageView;
|
|
51
47
|
|
|
52
|
-
|
|
53
|
-
@property (nonatomic, assign) BOOL ignoreRegionChanges;
|
|
54
|
-
|
|
55
|
-
@property (nonatomic, copy) RCTBubblingEventBlock onMapReady;
|
|
56
48
|
@property (nonatomic, copy) RCTBubblingEventBlock onChange;
|
|
57
|
-
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
|
|
58
|
-
@property (nonatomic, copy) RCTBubblingEventBlock onPanDrag;
|
|
59
49
|
@property (nonatomic, copy) RCTBubblingEventBlock onDoublePress;
|
|
60
50
|
@property (nonatomic, copy) RCTBubblingEventBlock onLongPress;
|
|
61
|
-
@property (nonatomic, copy)
|
|
62
|
-
@property (nonatomic, copy)
|
|
51
|
+
@property (nonatomic, copy) RCTBubblingEventBlock onMapReady;
|
|
52
|
+
@property (nonatomic, copy) RCTBubblingEventBlock onPanDrag;
|
|
53
|
+
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
|
|
54
|
+
@property (nonatomic, copy) RCTBubblingEventBlock onTilesRendered;
|
|
55
|
+
@property (nonatomic, copy) RCTBubblingEventBlock onUserLocationChange;
|
|
56
|
+
@property (nonatomic, copy) RCTDirectEventBlock onCalloutPress;
|
|
63
57
|
@property (nonatomic, copy) RCTDirectEventBlock onMarkerDeselect;
|
|
64
|
-
@property (nonatomic, copy) RCTDirectEventBlock onMarkerDragStart;
|
|
65
58
|
@property (nonatomic, copy) RCTDirectEventBlock onMarkerDrag;
|
|
66
59
|
@property (nonatomic, copy) RCTDirectEventBlock onMarkerDragEnd;
|
|
67
|
-
@property (nonatomic, copy) RCTDirectEventBlock
|
|
60
|
+
@property (nonatomic, copy) RCTDirectEventBlock onMarkerDragStart;
|
|
61
|
+
@property (nonatomic, copy) RCTDirectEventBlock onMarkerPress;
|
|
62
|
+
@property (nonatomic, copy) RCTDirectEventBlock onMarkerSelect;
|
|
68
63
|
@property (nonatomic, copy) RCTDirectEventBlock onRegionChange;
|
|
69
|
-
@property (nonatomic, copy) RCTBubblingEventBlock onTilesRendered;
|
|
70
|
-
@property (nonatomic, copy) RCTBubblingEventBlock onUserLocationChange;
|
|
71
64
|
|
|
72
65
|
- (void)cacheViewIfNeeded;
|
|
73
|
-
- (void)beginLoading;
|
|
74
66
|
- (void)finishLoading;
|
|
75
67
|
- (NSArray *)getMapBoundaries;
|
|
76
68
|
|
package/ios/Maps/RNMMap.m
CHANGED
|
@@ -86,6 +86,7 @@ const NSInteger RNMMapMaxZoomLevel = 20;
|
|
|
86
86
|
self.minZoomLevel = 0;
|
|
87
87
|
self.maxZoomLevel = RNMMapMaxZoomLevel;
|
|
88
88
|
self.compassOffset = CGPointMake(0, 0);
|
|
89
|
+
self.mapChangedFromUserInteraction = NO;
|
|
89
90
|
}
|
|
90
91
|
return self;
|
|
91
92
|
}
|
|
@@ -405,6 +406,11 @@ const NSInteger RNMMapMaxZoomLevel = 20;
|
|
|
405
406
|
region.span.longitudeDelta = self.region.span.longitudeDelta;
|
|
406
407
|
}
|
|
407
408
|
|
|
409
|
+
// If the region was changed with an animation, there is no way it was a user interaction
|
|
410
|
+
if (animated) {
|
|
411
|
+
self.mapChangedFromUserInteraction = NO;
|
|
412
|
+
}
|
|
413
|
+
|
|
408
414
|
// Animate/move to new position
|
|
409
415
|
[super setRegion:region animated:animated];
|
|
410
416
|
}
|
|
@@ -418,6 +424,11 @@ const NSInteger RNMMapMaxZoomLevel = 20;
|
|
|
418
424
|
|
|
419
425
|
- (void)setCamera:(MKMapCamera*)camera animated:(BOOL)animated
|
|
420
426
|
{
|
|
427
|
+
// If the camera was changed with an animation, there is no way it was a user interaction
|
|
428
|
+
if (animated) {
|
|
429
|
+
self.mapChangedFromUserInteraction = NO;
|
|
430
|
+
}
|
|
431
|
+
|
|
421
432
|
[super setCamera:camera animated:animated];
|
|
422
433
|
}
|
|
423
434
|
|
|
@@ -431,43 +442,6 @@ const NSInteger RNMMapMaxZoomLevel = 20;
|
|
|
431
442
|
|
|
432
443
|
- (void)setCacheEnabled:(BOOL)cacheEnabled {
|
|
433
444
|
_cacheEnabled = cacheEnabled;
|
|
434
|
-
if (self.cacheEnabled && self.cacheImageView.image == nil) {
|
|
435
|
-
self.loadingView.hidden = NO;
|
|
436
|
-
[self.activityIndicatorView startAnimating];
|
|
437
|
-
}
|
|
438
|
-
else {
|
|
439
|
-
if (_loadingView != nil) {
|
|
440
|
-
self.loadingView.hidden = YES;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
- (void)setLoadingEnabled:(BOOL)loadingEnabled {
|
|
446
|
-
_loadingEnabled = loadingEnabled;
|
|
447
|
-
if (!self.hasShownInitialLoading) {
|
|
448
|
-
self.loadingView.hidden = !self.loadingEnabled;
|
|
449
|
-
}
|
|
450
|
-
else {
|
|
451
|
-
if (_loadingView != nil) {
|
|
452
|
-
self.loadingView.hidden = YES;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
- (UIColor *)loadingBackgroundColor {
|
|
458
|
-
return self.loadingView.backgroundColor;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
- (void)setLoadingBackgroundColor:(UIColor *)loadingBackgroundColor {
|
|
462
|
-
self.loadingView.backgroundColor = loadingBackgroundColor;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
- (UIColor *)loadingIndicatorColor {
|
|
466
|
-
return self.activityIndicatorView.color;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
- (void)setLoadingIndicatorColor:(UIColor *)loadingIndicatorColor {
|
|
470
|
-
self.activityIndicatorView.color = loadingIndicatorColor;
|
|
471
445
|
}
|
|
472
446
|
|
|
473
447
|
// Include properties of MKMapView which are only available on iOS 9+
|
|
@@ -549,7 +523,7 @@ const NSInteger RNMMapMaxZoomLevel = 20;
|
|
|
549
523
|
if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateActive) {
|
|
550
524
|
return;
|
|
551
525
|
}
|
|
552
|
-
if (self.
|
|
526
|
+
if (self.mapLoaded) {
|
|
553
527
|
if (!self.cacheEnabled) {
|
|
554
528
|
if (_cacheImageView != nil) {
|
|
555
529
|
self.cacheImageView.hidden = YES;
|
|
@@ -612,48 +586,11 @@ const NSInteger RNMMapMaxZoomLevel = 20;
|
|
|
612
586
|
return self.layoutMargins;
|
|
613
587
|
}
|
|
614
588
|
|
|
615
|
-
- (void)beginLoading {
|
|
616
|
-
if ((!self.hasShownInitialLoading && self.loadingEnabled) || (self.cacheEnabled && self.cacheImageView.image == nil)) {
|
|
617
|
-
self.loadingView.hidden = NO;
|
|
618
|
-
[self.activityIndicatorView startAnimating];
|
|
619
|
-
}
|
|
620
|
-
else {
|
|
621
|
-
if (_loadingView != nil) {
|
|
622
|
-
self.loadingView.hidden = YES;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
|
|
627
589
|
- (void)finishLoading {
|
|
628
|
-
self.
|
|
629
|
-
if (_loadingView != nil) {
|
|
630
|
-
self.loadingView.hidden = YES;
|
|
631
|
-
}
|
|
590
|
+
self.mapLoaded = YES;
|
|
632
591
|
[self cacheViewIfNeeded];
|
|
633
592
|
}
|
|
634
593
|
|
|
635
|
-
- (UIActivityIndicatorView *)activityIndicatorView {
|
|
636
|
-
if (_activityIndicatorView == nil) {
|
|
637
|
-
_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
|
|
638
|
-
_activityIndicatorView.center = self.loadingView.center;
|
|
639
|
-
_activityIndicatorView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
|
|
640
|
-
_activityIndicatorView.color = [UIColor colorWithRed:96.f/255.f green:96.f/255.f blue:96.f/255.f alpha:1.f]; // defaults to #606060
|
|
641
|
-
}
|
|
642
|
-
[self.loadingView addSubview:_activityIndicatorView];
|
|
643
|
-
return _activityIndicatorView;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
- (UIView *)loadingView {
|
|
647
|
-
if (_loadingView == nil) {
|
|
648
|
-
_loadingView = [[UIView alloc] initWithFrame:self.bounds];
|
|
649
|
-
_loadingView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
|
|
650
|
-
_loadingView.backgroundColor = [UIColor whiteColor]; // defaults to #FFFFFF
|
|
651
|
-
[self addSubview:_loadingView];
|
|
652
|
-
_loadingView.hidden = NO;
|
|
653
|
-
}
|
|
654
|
-
return _loadingView;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
594
|
- (UIImageView *)cacheImageView {
|
|
658
595
|
if (_cacheImageView == nil) {
|
|
659
596
|
_cacheImageView = [[UIImageView alloc] initWithFrame:self.bounds];
|
package/ios/Maps/RNMMapManager.m
CHANGED
|
@@ -89,9 +89,6 @@ RCT_EXPORT_VIEW_PROPERTY(handlePanDrag, BOOL)
|
|
|
89
89
|
RCT_EXPORT_VIEW_PROPERTY(isAccessibilityElement, BOOL)
|
|
90
90
|
RCT_EXPORT_VIEW_PROPERTY(kmlSrc, NSString)
|
|
91
91
|
RCT_EXPORT_VIEW_PROPERTY(legalLabelInsets, UIEdgeInsets)
|
|
92
|
-
RCT_EXPORT_VIEW_PROPERTY(loadingBackgroundColor, UIColor)
|
|
93
|
-
RCT_EXPORT_VIEW_PROPERTY(loadingEnabled, BOOL)
|
|
94
|
-
RCT_EXPORT_VIEW_PROPERTY(loadingIndicatorColor, UIColor)
|
|
95
92
|
RCT_EXPORT_VIEW_PROPERTY(mapPadding, UIEdgeInsets)
|
|
96
93
|
RCT_EXPORT_VIEW_PROPERTY(mapType, MKMapType)
|
|
97
94
|
RCT_EXPORT_VIEW_PROPERTY(maxDelta, CGFloat)
|
|
@@ -516,6 +513,24 @@ static int kDragCenterContext;
|
|
|
516
513
|
[self _regionChanged:mapView];
|
|
517
514
|
}
|
|
518
515
|
|
|
516
|
+
- (BOOL)mapViewRegionDidChangeFromUserInteraction:(RNMMap *)mapView
|
|
517
|
+
{
|
|
518
|
+
UIView *view = mapView.subviews.firstObject;
|
|
519
|
+
// Look through gesture recognizers to determine whether this region change is from user interaction
|
|
520
|
+
for(UIGestureRecognizer *recognizer in view.gestureRecognizers) {
|
|
521
|
+
if(recognizer.state == UIGestureRecognizerStateBegan || recognizer.state == UIGestureRecognizerStateChanged || recognizer.state == UIGestureRecognizerStateEnded) {
|
|
522
|
+
return YES;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
return NO;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
- (void)mapView:(RNMMap *)mapView regionWillChangeAnimated:(BOOL)animated
|
|
530
|
+
{
|
|
531
|
+
mapView.mapChangedFromUserInteraction = [self mapViewRegionDidChangeFromUserInteraction: mapView];
|
|
532
|
+
}
|
|
533
|
+
|
|
519
534
|
- (void)mapView:(RNMMap *)mapView regionDidChangeAnimated:(__unused BOOL)animated
|
|
520
535
|
{
|
|
521
536
|
CGFloat zoomLevel = [self zoomLevel:mapView];
|
|
@@ -549,7 +564,6 @@ static int kDragCenterContext;
|
|
|
549
564
|
mapView.onMapReady(@{});
|
|
550
565
|
mapView.hasStartedRendering = YES;
|
|
551
566
|
}
|
|
552
|
-
[mapView beginLoading];
|
|
553
567
|
}
|
|
554
568
|
|
|
555
569
|
- (void)mapViewDidFinishRenderingMap:(RNMMap *)mapView fullyRendered:(__unused BOOL)fullyRendered
|
|
@@ -602,6 +616,7 @@ static int kDragCenterContext;
|
|
|
602
616
|
#define FLUSH_NAN(value) (isnan(value) ? 0 : value)
|
|
603
617
|
mapView.onChange(@{
|
|
604
618
|
@"continuous": @(continuous),
|
|
619
|
+
@"isGesture": @(mapView.mapChangedFromUserInteraction),
|
|
605
620
|
@"region": @{
|
|
606
621
|
@"latitude": @(FLUSH_NAN(region.center.latitude)),
|
|
607
622
|
@"longitude": @(FLUSH_NAN(region.center.longitude)),
|
package/lib/MapView.d.ts
CHANGED
|
@@ -108,30 +108,6 @@ export type MapViewProps = ViewProps & {
|
|
|
108
108
|
* @platform Android: Supported
|
|
109
109
|
*/
|
|
110
110
|
liteMode?: boolean;
|
|
111
|
-
/**
|
|
112
|
-
* Sets loading background color.
|
|
113
|
-
*
|
|
114
|
-
* @default `#FFFFFF`
|
|
115
|
-
* @platform iOS: Apple Maps only
|
|
116
|
-
* @platform Android: Supported
|
|
117
|
-
*/
|
|
118
|
-
loadingBackgroundColor?: string;
|
|
119
|
-
/**
|
|
120
|
-
* If `true` a loading indicator will show while the map is loading.
|
|
121
|
-
*
|
|
122
|
-
* @default false
|
|
123
|
-
* @platform iOS: Apple Maps only
|
|
124
|
-
* @platform Android: Supported
|
|
125
|
-
*/
|
|
126
|
-
loadingEnabled?: boolean;
|
|
127
|
-
/**
|
|
128
|
-
* Sets loading indicator color.
|
|
129
|
-
*
|
|
130
|
-
* @default `#606060`
|
|
131
|
-
* @platform iOS: Apple Maps only
|
|
132
|
-
* @platform Android: Supported
|
|
133
|
-
*/
|
|
134
|
-
loadingIndicatorColor?: string;
|
|
135
111
|
/**
|
|
136
112
|
* Adds custom padding to each side of the map. Useful when map elements/markers are obscured.
|
|
137
113
|
*
|
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": "2.0.0-beta.
|
|
8
|
+
"version": "2.0.0-beta.15",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|