react-native-maps 1.21.0-alpha.7 → 1.21.0-alpha.71
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/build.gradle +38 -13
- package/android/generated/RCTAppDependencyProvider.h +25 -0
- package/android/generated/RCTAppDependencyProvider.mm +55 -0
- package/android/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/android/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/android/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/android/generated/RCTThirdPartyComponentsProvider.mm +26 -0
- package/android/generated/ReactAppDependencyProvider.podspec +34 -0
- package/android/generated/java/com/facebook/fbreact/specs/NativeAirMapsModuleSpec.java +63 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerDelegate.java +35 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerInterface.java +17 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerDelegate.java +200 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerInterface.java +71 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerDelegate.java +104 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerInterface.java +39 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNMapsSpecs-generated.cpp +68 -0
- package/android/generated/jni/RNMapsSpecs.h +31 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +26 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +28 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +918 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +787 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.cpp +154 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.h +1058 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI-generated.cpp +74 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI.h +268 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +21 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +76 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.h +77 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/java/com/rnmaps/fabric/CalloutManager.java +77 -0
- package/android/src/main/java/com/rnmaps/fabric/JSONUtil.java +86 -0
- package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +593 -0
- package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +259 -0
- package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +156 -4
- package/android/src/main/java/com/rnmaps/fabric/event/OnCalloutPressEvent.java +25 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnDeselectEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnDragEndEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnDragEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnDragStartEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnLongPressEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMapLoadedEvent.java +29 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMapReadyEvent.java +29 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDeselectEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragEndEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragStartEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerPressEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerSelectEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnPoiClickEvent.java +27 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnPressEvent.java +27 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeCompleteEvent.java +30 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeEvent.java +48 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeStartEvent.java +33 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnSelectEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnUserLocationChangeEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +22 -2
- package/android/src/main/java/com/rnmaps/maps/MapCallout.java +18 -0
- package/android/src/main/java/com/rnmaps/maps/MapManager.java +14 -14
- package/android/src/main/java/com/rnmaps/maps/MapMarker.java +79 -3
- package/android/src/main/java/com/rnmaps/maps/MapModule.java +206 -206
- package/android/src/main/java/com/rnmaps/maps/MapView.java +1618 -1346
- package/ios/AirGoogleMaps/AIRGoogleMap.h +3 -2
- package/ios/AirGoogleMaps/AIRGoogleMap.m +153 -48
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +23 -11
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +17 -28
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +347 -243
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +2 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +30 -0
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +0 -7
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +2 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +3 -3
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +161 -61
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +25 -0
- package/ios/AirMaps/AIRMap.h +6 -3
- package/ios/AirMaps/AIRMap.m +289 -145
- package/ios/AirMaps/AIRMapManager.m +8 -17
- package/ios/AirMaps/AIRMapMarker.h +1 -0
- package/ios/AirMaps/AIRMapMarker.m +165 -103
- package/ios/AirMaps/Callout/SMCalloutView.m +1 -1
- package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
- package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
- package/ios/AirMaps/RNMapsAirModule.h +1 -1
- package/ios/AirMaps/RNMapsAirModule.mm +42 -172
- package/ios/AirMaps/RNMapsAirModuleDelegate.h +24 -0
- package/ios/AirMaps/RNMapsHostVewDelegate.h +17 -0
- package/ios/AirMaps/RNMapsMapView.h +3 -3
- package/ios/AirMaps/RNMapsMapView.mm +344 -307
- package/ios/AirMaps/RNMapsMarkerView.h +24 -0
- package/ios/AirMaps/RNMapsMarkerView.mm +430 -0
- package/ios/AirMaps/RNMapsMarkerViewManager.mm +21 -0
- package/ios/AirMaps/UIView +AirMap.m +20 -0
- package/ios/AirMaps/UIView+AirMap.h +11 -0
- package/ios/AirMaps.xcodeproj/project.pbxproj +60 -0
- package/ios/generated/RCTAppDependencyProvider.h +25 -0
- package/ios/generated/RCTAppDependencyProvider.mm +55 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.mm +26 -0
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +26 -0
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +28 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.cpp +918 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.h +787 -0
- package/ios/generated/RNMapsSpecs/Props.cpp +154 -0
- package/ios/generated/RNMapsSpecs/Props.h +1058 -0
- package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +549 -0
- package/ios/generated/RNMapsSpecs/RNMapsSpecs-generated.mm +92 -0
- package/ios/generated/RNMapsSpecs/RNMapsSpecs.h +137 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +21 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.h +76 -0
- package/ios/generated/RNMapsSpecs/States.cpp +16 -0
- package/ios/generated/RNMapsSpecs/States.h +77 -0
- package/ios/generated/RNMapsSpecsJSI-generated.cpp +74 -0
- package/ios/generated/RNMapsSpecsJSI.h +268 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/lib/MapCallout.js +1 -0
- package/lib/MapMarker.d.ts +15 -2
- package/lib/MapMarker.js +53 -9
- package/lib/MapMarkerNativeComponent.js +0 -2
- package/lib/MapOverlay.js +2 -8
- package/lib/MapPolyline.d.ts +1 -1
- package/lib/MapView.d.ts +7 -22
- package/lib/MapView.js +83 -94
- package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -11
- package/lib/createFabricMap.js +175 -0
- package/lib/decorateMapComponent.js +22 -0
- package/lib/specs/NativeAirMapsModule.d.ts +2 -2
- package/lib/specs/NativeComponentCallout.d.ts +46 -0
- package/lib/specs/NativeComponentCallout.js +9 -0
- package/lib/specs/NativeComponentGoogleMapView.d.ts +12 -12
- package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
- package/lib/specs/NativeComponentGooglePolygon.js +9 -0
- package/lib/specs/NativeComponentMapView.d.ts +19 -36
- package/lib/specs/NativeComponentMapView.js +1 -3
- package/lib/specs/NativeComponentMarker.d.ts +258 -0
- package/lib/specs/NativeComponentMarker.js +19 -0
- package/package.json +15 -10
- package/react-native-maps.podspec +2 -1
- package/lib/FabricMapView.js +0 -181
|
@@ -350,23 +350,8 @@ RCT_EXPORT_METHOD(fitToCoordinates:(nonnull NSNumber *)reactTag
|
|
|
350
350
|
RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
|
|
351
351
|
} else {
|
|
352
352
|
AIRMap *mapView = (AIRMap *)view;
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
CLLocationCoordinate2D coords[coordinates.count];
|
|
356
|
-
for(int i = 0; i < coordinates.count; i++)
|
|
357
|
-
{
|
|
358
|
-
coords[i] = coordinates[i].coordinate;
|
|
359
|
-
}
|
|
360
|
-
MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordinates.count];
|
|
361
|
-
|
|
362
|
-
// Set Map viewport
|
|
363
|
-
CGFloat top = [RCTConvert CGFloat:edgePadding[@"top"]];
|
|
364
|
-
CGFloat right = [RCTConvert CGFloat:edgePadding[@"right"]];
|
|
365
|
-
CGFloat bottom = [RCTConvert CGFloat:edgePadding[@"bottom"]];
|
|
366
|
-
CGFloat left = [RCTConvert CGFloat:edgePadding[@"left"]];
|
|
367
|
-
|
|
368
|
-
[mapView setVisibleMapRect:[polyline boundingMapRect] edgePadding:UIEdgeInsetsMake(top, left, bottom, right) animated:animated];
|
|
369
|
-
|
|
353
|
+
UIEdgeInsets edgeInsets = [RCTConvert UIEdgeInsets:edgePadding];
|
|
354
|
+
[mapView fitToCoordinates: coordinates edgePadding:edgeInsets animated:animated];
|
|
370
355
|
}
|
|
371
356
|
}];
|
|
372
357
|
}
|
|
@@ -950,6 +935,9 @@ static int kDragCenterContext;
|
|
|
950
935
|
{
|
|
951
936
|
// Don't send region did change events until map has
|
|
952
937
|
// started rendering, as these won't represent the final location
|
|
938
|
+
if (animated && mapView.ignoreRegionChanges){
|
|
939
|
+
mapView.ignoreRegionChanges = false;
|
|
940
|
+
}
|
|
953
941
|
if(mapView.hasStartedRendering){
|
|
954
942
|
[self _regionChanged:mapView];
|
|
955
943
|
}
|
|
@@ -966,6 +954,8 @@ static int kDragCenterContext;
|
|
|
966
954
|
|
|
967
955
|
mapView.pendingCenter = mapView.region.center;
|
|
968
956
|
mapView.pendingSpan = mapView.region.span;
|
|
957
|
+
// reset original state (checkout setCamera / region animated)
|
|
958
|
+
mapView.ignoreRegionChanges = NO;
|
|
969
959
|
}
|
|
970
960
|
|
|
971
961
|
- (void)mapViewWillStartRenderingMap:(AIRMap *)mapView
|
|
@@ -980,6 +970,7 @@ static int kDragCenterContext;
|
|
|
980
970
|
- (void)mapViewDidFinishRenderingMap:(AIRMap *)mapView fullyRendered:(BOOL)fullyRendered
|
|
981
971
|
{
|
|
982
972
|
[mapView finishLoading];
|
|
973
|
+
mapView.ignoreRegionChanges = NO;
|
|
983
974
|
}
|
|
984
975
|
|
|
985
976
|
#pragma mark Private
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
#import <React/RCTImageLoaderProtocol.h>
|
|
15
15
|
#import <React/RCTUtils.h>
|
|
16
16
|
#import <React/UIView+React.h>
|
|
17
|
+
#import <React/RCTImageLoader.h>
|
|
18
|
+
#import <React/RCTBridge+Private.h>
|
|
17
19
|
|
|
18
20
|
NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
19
21
|
|
|
@@ -28,6 +30,13 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
28
30
|
BOOL _calloutIsOpen;
|
|
29
31
|
NSInteger _zIndexBeforeOpen;
|
|
30
32
|
BOOL _useLegacyPinView;
|
|
33
|
+
|
|
34
|
+
CADisplayLink *_displayLink;
|
|
35
|
+
CLLocationCoordinate2D _startCoordinate;
|
|
36
|
+
CLLocationCoordinate2D _endCoordinate;
|
|
37
|
+
NSTimeInterval _animationStartTime;
|
|
38
|
+
NSTimeInterval _animationDuration;
|
|
39
|
+
BOOL _isAnimating;
|
|
31
40
|
}
|
|
32
41
|
|
|
33
42
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
@@ -43,22 +52,22 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
43
52
|
// Make sure we use the image size when available
|
|
44
53
|
CGSize size = self.image ? self.image.size : frame.size;
|
|
45
54
|
CGRect bounds = {CGPointZero, size};
|
|
46
|
-
|
|
55
|
+
|
|
47
56
|
// The MapView is basically in charge of figuring out the center position of the marker view. If the view changed in
|
|
48
57
|
// height though, we need to compensate in such a way that the bottom of the marker stays at the same spot on the
|
|
49
58
|
// map.
|
|
50
59
|
CGFloat dy = (bounds.size.height - self.bounds.size.height) / 2;
|
|
51
60
|
CGPoint center = (CGPoint){ self.center.x, self.center.y - dy };
|
|
52
|
-
|
|
61
|
+
|
|
53
62
|
// Avoid crashes due to nan coords
|
|
54
63
|
if (isnan(center.x) || isnan(center.y) ||
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
isnan(bounds.origin.x) || isnan(bounds.origin.y) ||
|
|
65
|
+
isnan(bounds.size.width) || isnan(bounds.size.height)) {
|
|
57
66
|
RCTLogError(@"Invalid layout for (%@)%@. position: %@. bounds: %@",
|
|
58
|
-
|
|
67
|
+
self.reactTag, self, NSStringFromCGPoint(center), NSStringFromCGRect(bounds));
|
|
59
68
|
return;
|
|
60
69
|
}
|
|
61
|
-
|
|
70
|
+
|
|
62
71
|
self.center = center;
|
|
63
72
|
self.bounds = bounds;
|
|
64
73
|
}
|
|
@@ -68,6 +77,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
68
77
|
self.calloutView = (AIRMapCallout *)subview;
|
|
69
78
|
} else {
|
|
70
79
|
[super insertReactSubview:(UIView *)subview atIndex:atIndex];
|
|
80
|
+
[self addSubview:subview];
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
83
|
- (void) setFrame:(CGRect)frame {
|
|
@@ -84,6 +94,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
84
94
|
self.calloutView = nil;
|
|
85
95
|
} else {
|
|
86
96
|
[super removeReactSubview:(UIView *)subview];
|
|
97
|
+
[(UIView *) subview removeFromSuperview];
|
|
87
98
|
}
|
|
88
99
|
}
|
|
89
100
|
|
|
@@ -91,36 +102,40 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
91
102
|
{
|
|
92
103
|
if ([self shouldUsePinView]) {
|
|
93
104
|
// In this case, we want to render a platform "default" legacy marker.
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
|
|
106
|
+
|
|
96
107
|
if (_pinView == nil && _useLegacyPinView) {
|
|
97
108
|
_pinView = [[MKPinAnnotationView alloc] initWithAnnotation:self reuseIdentifier: nil];
|
|
98
109
|
[self addGestureRecognizerToView:_pinView];
|
|
99
110
|
_pinView.annotation = self;
|
|
100
|
-
|
|
111
|
+
|
|
101
112
|
if ([_pinView respondsToSelector:@selector(setPinTintColor:)]) {
|
|
102
113
|
_pinView.pinTintColor = self.pinColor;
|
|
103
114
|
}
|
|
104
|
-
|
|
115
|
+
|
|
105
116
|
_pinView.draggable = self.draggable;
|
|
106
117
|
_pinView.layer.zPosition = self.zIndex;
|
|
107
|
-
|
|
118
|
+
_pinView.displayPriority = self.displayPriority;
|
|
119
|
+
_pinView.zPriority = self.zIndex;
|
|
108
120
|
return _pinView;
|
|
109
121
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
113
125
|
if (_markerView == nil && !_useLegacyPinView) {
|
|
114
126
|
_markerView = [[MKMarkerAnnotationView alloc] initWithAnnotation:self reuseIdentifier: nil];
|
|
115
127
|
[self addGestureRecognizerToView:_markerView];
|
|
116
128
|
_markerView.annotation = self;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
129
|
+
|
|
130
|
+
_markerView.draggable = self.draggable;
|
|
131
|
+
_markerView.layer.zPosition = self.zIndex;
|
|
132
|
+
_markerView.markerTintColor = self.pinColor;
|
|
133
|
+
_markerView.titleVisibility = self.titleVisibility ?: MKFeatureVisibilityHidden;
|
|
134
|
+
_markerView.subtitleVisibility = self.subtitleVisibility ?: MKFeatureVisibilityHidden;
|
|
135
|
+
_markerView.displayPriority = self.displayPriority;
|
|
136
|
+
_markerView.zPriority = self.zIndex;
|
|
137
|
+
|
|
138
|
+
|
|
124
139
|
}
|
|
125
140
|
return _markerView ?: _pinView;
|
|
126
141
|
} else {
|
|
@@ -129,6 +144,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
129
144
|
// In either case, we want to return the AIRMapMarker since it is both an MKAnnotation and an
|
|
130
145
|
// MKAnnotationView all at the same time.
|
|
131
146
|
self.layer.zPosition = self.zIndex;
|
|
147
|
+
self.zPriority = self.zIndex;
|
|
132
148
|
return self;
|
|
133
149
|
}
|
|
134
150
|
}
|
|
@@ -136,14 +152,14 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
136
152
|
- (void)fillCalloutView:(SMCalloutView *)calloutView
|
|
137
153
|
{
|
|
138
154
|
// Set everything necessary on the calloutView before it becomes visible.
|
|
139
|
-
|
|
155
|
+
|
|
140
156
|
// Apply the MKAnnotationView's desired calloutOffset (from the top-middle of the view)
|
|
141
|
-
|
|
157
|
+
if ([self shouldUsePinView] && !_hasSetCalloutOffset && _useLegacyPinView) {
|
|
142
158
|
calloutView.calloutOffset = CGPointMake(-8,0);
|
|
143
159
|
} else {
|
|
144
160
|
calloutView.calloutOffset = self.calloutOffset;
|
|
145
161
|
}
|
|
146
|
-
|
|
162
|
+
|
|
147
163
|
if (self.calloutView) {
|
|
148
164
|
calloutView.title = nil;
|
|
149
165
|
calloutView.subtitle = nil;
|
|
@@ -156,13 +172,13 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
156
172
|
// as a result, we use the default "masked" background view.
|
|
157
173
|
calloutView.backgroundView = [SMCalloutMaskedBackgroundView new];
|
|
158
174
|
}
|
|
159
|
-
|
|
175
|
+
|
|
160
176
|
// when this is set, the callout's content will be whatever react views the user has put as the callout's
|
|
161
177
|
// children.
|
|
162
178
|
calloutView.contentView = self.calloutView;
|
|
163
|
-
|
|
179
|
+
|
|
164
180
|
} else {
|
|
165
|
-
|
|
181
|
+
|
|
166
182
|
// if there is no calloutView, it means the user wants to use the default callout behavior with title/subtitle
|
|
167
183
|
// pairs.
|
|
168
184
|
calloutView.title = self.title;
|
|
@@ -176,37 +192,37 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
176
192
|
{
|
|
177
193
|
_calloutIsOpen = YES;
|
|
178
194
|
[self setZIndex:_zIndexBeforeOpen];
|
|
179
|
-
|
|
195
|
+
|
|
180
196
|
MKAnnotationView *annotationView = [self getAnnotationView];
|
|
181
|
-
|
|
197
|
+
|
|
182
198
|
[self setSelected:YES animated:NO];
|
|
183
199
|
[self.map selectAnnotation:self animated:NO];
|
|
184
|
-
|
|
200
|
+
|
|
185
201
|
id event = @{
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
202
|
+
@"action": @"marker-select",
|
|
203
|
+
@"id": self.identifier ?: @"unknown",
|
|
204
|
+
@"coordinate": @{
|
|
205
|
+
@"latitude": @(self.coordinate.latitude),
|
|
206
|
+
@"longitude": @(self.coordinate.longitude)
|
|
207
|
+
}
|
|
192
208
|
};
|
|
193
|
-
|
|
209
|
+
|
|
194
210
|
if (self.map.onMarkerSelect) self.map.onMarkerSelect(event);
|
|
195
211
|
if (self.onSelect) self.onSelect(event);
|
|
196
|
-
|
|
212
|
+
|
|
197
213
|
if (![self shouldShowCalloutView]) {
|
|
198
214
|
// no callout to show
|
|
199
215
|
return;
|
|
200
216
|
}
|
|
201
|
-
|
|
217
|
+
|
|
202
218
|
[self fillCalloutView:self.map.calloutView];
|
|
203
|
-
|
|
219
|
+
|
|
204
220
|
// This is where we present our custom callout view... MapKit's built-in callout doesn't have the flexibility
|
|
205
221
|
// we need, but a lot of work was done by Nick Farina to make this identical to MapKit's built-in.
|
|
206
222
|
[self.map.calloutView presentCalloutFromRect:annotationView.bounds
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
223
|
+
inView:annotationView
|
|
224
|
+
constrainedToView:self.map
|
|
225
|
+
animated:YES];
|
|
210
226
|
}
|
|
211
227
|
|
|
212
228
|
#pragma mark - Tap Gesture & Events.
|
|
@@ -228,12 +244,12 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
228
244
|
- (void)_handleTap:(UITapGestureRecognizer *)recognizer {
|
|
229
245
|
AIRMapMarker *marker = self;
|
|
230
246
|
if (!marker) return;
|
|
231
|
-
|
|
247
|
+
|
|
232
248
|
if (marker.selected) {
|
|
233
249
|
CGPoint touchPoint = [recognizer locationInView:marker.map.calloutView];
|
|
234
250
|
CGRect bubbleFrame = [self.calloutView convertRect:marker.map.calloutView.bounds toView:marker.map];
|
|
235
251
|
CGPoint touchPointReal = [recognizer locationInView:self.calloutView];
|
|
236
|
-
|
|
252
|
+
|
|
237
253
|
UIView *calloutView = [marker.map.calloutView hitTest:touchPoint withEvent:nil];
|
|
238
254
|
if (calloutView) {
|
|
239
255
|
// the callout (or its subview) got clicked, not the marker
|
|
@@ -247,22 +263,22 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
247
263
|
}
|
|
248
264
|
tmp = tmp.superview;
|
|
249
265
|
}
|
|
250
|
-
|
|
266
|
+
|
|
251
267
|
id event = @{
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
268
|
+
@"action": calloutSubview ? @"callout-inside-press" : @"callout-press",
|
|
269
|
+
@"id": marker.identifier ?: @"unknown",
|
|
270
|
+
@"point": @{
|
|
271
|
+
@"x": @(touchPointReal.x),
|
|
272
|
+
@"y": @(touchPointReal.y),
|
|
273
|
+
},
|
|
274
|
+
@"frame": @{
|
|
275
|
+
@"x": @(bubbleFrame.origin.x),
|
|
276
|
+
@"y": @(bubbleFrame.origin.y),
|
|
277
|
+
@"width": @(bubbleFrame.size.width),
|
|
278
|
+
@"height": @(bubbleFrame.size.height),
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
|
|
266
282
|
if (calloutSubview) calloutSubview.onPress(event);
|
|
267
283
|
if (marker.onCalloutPress) marker.onCalloutPress(event);
|
|
268
284
|
if (marker.calloutView && marker.calloutView.onPress) marker.calloutView.onPress(event);
|
|
@@ -270,25 +286,25 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
270
286
|
return;
|
|
271
287
|
}
|
|
272
288
|
}
|
|
273
|
-
|
|
289
|
+
|
|
274
290
|
// the actual marker got clicked
|
|
275
291
|
CGPoint touchPointReal = [recognizer locationInView:self.calloutView];
|
|
276
292
|
id event = @{
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
293
|
+
@"action": @"marker-press",
|
|
294
|
+
@"id": marker.identifier ?: @"unknown",
|
|
295
|
+
@"coordinate": @{
|
|
296
|
+
@"latitude": @(marker.coordinate.latitude),
|
|
297
|
+
@"longitude": @(marker.coordinate.longitude)
|
|
298
|
+
},
|
|
299
|
+
@"position": @{
|
|
300
|
+
@"x": @(touchPointReal.x),
|
|
301
|
+
@"y": @(touchPointReal.y),
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
|
|
289
305
|
if (marker.onPress) marker.onPress(event);
|
|
290
306
|
if (marker.map.onMarkerPress) marker.map.onMarkerPress(event);
|
|
291
|
-
|
|
307
|
+
|
|
292
308
|
[marker.map selectAnnotation:marker animated:NO];
|
|
293
309
|
}
|
|
294
310
|
|
|
@@ -298,19 +314,19 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
298
314
|
[self setZIndex:_zIndexBeforeOpen];
|
|
299
315
|
// hide the callout view
|
|
300
316
|
[self.map.calloutView dismissCalloutAnimated:YES];
|
|
301
|
-
|
|
317
|
+
|
|
302
318
|
[self setSelected:NO animated:NO];
|
|
303
319
|
[self.map deselectAnnotation:self animated:NO];
|
|
304
|
-
|
|
320
|
+
|
|
305
321
|
id event = @{
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
322
|
+
@"action": @"marker-deselect",
|
|
323
|
+
@"id": self.identifier ?: @"unknown",
|
|
324
|
+
@"coordinate": @{
|
|
325
|
+
@"latitude": @(self.coordinate.latitude),
|
|
326
|
+
@"longitude": @(self.coordinate.longitude)
|
|
327
|
+
}
|
|
312
328
|
};
|
|
313
|
-
|
|
329
|
+
|
|
314
330
|
if (self.map.onMarkerDeselect) self.map.onMarkerDeselect(event);
|
|
315
331
|
if (self.onDeselect) self.onDeselect(event);
|
|
316
332
|
}
|
|
@@ -333,39 +349,42 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
333
349
|
|
|
334
350
|
- (void)setOpacity:(double)opacity
|
|
335
351
|
{
|
|
336
|
-
|
|
352
|
+
[self setAlpha:opacity];
|
|
337
353
|
}
|
|
338
354
|
|
|
339
355
|
- (void)setImageSrc:(NSString *)imageSrc
|
|
340
356
|
{
|
|
341
357
|
_imageSrc = imageSrc;
|
|
342
|
-
|
|
358
|
+
|
|
343
359
|
if (_reloadImageCancellationBlock) {
|
|
344
360
|
_reloadImageCancellationBlock();
|
|
345
361
|
_reloadImageCancellationBlock = nil;
|
|
346
362
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
+
__weak __typeof(self) weakSelf = self;
|
|
364
|
+
|
|
365
|
+
_reloadImageCancellationBlock = [[[RCTBridge currentBridge] moduleForName:@"ImageLoader"] loadImageWithURLRequest:[RCTConvert NSURLRequest:_imageSrc]
|
|
366
|
+
size:self.bounds.size
|
|
367
|
+
scale:RCTScreenScale()
|
|
368
|
+
clipped:YES
|
|
369
|
+
resizeMode:RCTResizeModeCenter
|
|
370
|
+
progressBlock:nil
|
|
371
|
+
partialLoadBlock:nil
|
|
372
|
+
completionBlock:^(NSError *error, UIImage *image) {
|
|
373
|
+
if (error) {
|
|
374
|
+
// TODO(lmr): do something with the error?
|
|
375
|
+
NSLog(@"failed to load image: %@", error);
|
|
376
|
+
}
|
|
377
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
378
|
+
__strong __typeof(weakSelf) strongSelf = weakSelf;
|
|
379
|
+
strongSelf.image = image;
|
|
380
|
+
});
|
|
381
|
+
}];
|
|
363
382
|
}
|
|
364
383
|
|
|
365
384
|
- (void)setPinColor:(UIColor *)pinColor
|
|
366
385
|
{
|
|
367
386
|
_pinColor = pinColor;
|
|
368
|
-
|
|
387
|
+
|
|
369
388
|
if(_useLegacyPinView && [_pinView respondsToSelector:@selector(setPinTintColor:)]) {
|
|
370
389
|
_pinView.pinTintColor = _pinColor;
|
|
371
390
|
} else {
|
|
@@ -381,7 +400,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
381
400
|
}
|
|
382
401
|
|
|
383
402
|
- (BOOL)isSelected {
|
|
384
|
-
|
|
403
|
+
return _isPreselected || [super isSelected];
|
|
385
404
|
}
|
|
386
405
|
|
|
387
406
|
- (void)dealloc {
|
|
@@ -398,4 +417,47 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
398
417
|
_useLegacyPinView = value;
|
|
399
418
|
}
|
|
400
419
|
|
|
420
|
+
- (void)animateToCoordinate:(CLLocationCoordinate2D)newCoordinate duration:(NSTimeInterval)duration {
|
|
421
|
+
if (_isAnimating) {
|
|
422
|
+
NSLog(@"Animation already in progress. Rejecting new animation request.");
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// Mark as animating
|
|
427
|
+
_isAnimating = YES;
|
|
428
|
+
|
|
429
|
+
// Store animation parameters
|
|
430
|
+
_startCoordinate = self.coordinate;
|
|
431
|
+
_endCoordinate = newCoordinate;
|
|
432
|
+
_animationDuration = duration;
|
|
433
|
+
_animationStartTime = [NSDate timeIntervalSinceReferenceDate];
|
|
434
|
+
|
|
435
|
+
// Start a CADisplayLink
|
|
436
|
+
if (_displayLink) {
|
|
437
|
+
[_displayLink invalidate];
|
|
438
|
+
}
|
|
439
|
+
_displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updatePosition)];
|
|
440
|
+
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
- (void)updatePosition {
|
|
444
|
+
NSTimeInterval elapsed = [NSDate timeIntervalSinceReferenceDate] - _animationStartTime;
|
|
445
|
+
CGFloat progress = MIN(elapsed / _animationDuration, 1.0);
|
|
446
|
+
|
|
447
|
+
// Interpolate coordinates
|
|
448
|
+
CLLocationDegrees currentLatitude = _startCoordinate.latitude + progress * (_endCoordinate.latitude - _startCoordinate.latitude);
|
|
449
|
+
CLLocationDegrees currentLongitude = _startCoordinate.longitude + progress * (_endCoordinate.longitude - _startCoordinate.longitude);
|
|
450
|
+
|
|
451
|
+
// Update annotation's coordinate
|
|
452
|
+
CLLocationCoordinate2D currentCoordinate = CLLocationCoordinate2DMake(currentLatitude, currentLongitude);
|
|
453
|
+
[self setValue:[NSValue valueWithMKCoordinate:currentCoordinate] forKey:@"coordinate"];
|
|
454
|
+
|
|
455
|
+
// Stop the animation when complete
|
|
456
|
+
if (progress == 1.0) {
|
|
457
|
+
[_displayLink invalidate];
|
|
458
|
+
_displayLink = nil;
|
|
459
|
+
_isAnimating = NO; // Reset the animation state
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
401
463
|
@end
|
|
@@ -855,4 +855,4 @@ static UIImage *blackArrowImage = nil, *whiteArrowImage = nil, *grayArrowImage =
|
|
|
855
855
|
- (CGFloat)frameBottom { return self.frame.origin.y + self.frame.size.height; }
|
|
856
856
|
- (void)setFrameBottom:(CGFloat)bottom { self.frame = (CGRect){ .origin=self.frame.origin, .size.width=self.frame.size.width, .size.height=fmaxf(bottom-self.frame.origin.y,0) }; }
|
|
857
857
|
|
|
858
|
-
@end
|
|
858
|
+
@end
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
#import <MapKit/MapKit.h>
|
|
8
8
|
#import <React/RCTConvert.h>
|
|
9
9
|
|
|
10
|
+
@class AIRMapCoordinate;
|
|
11
|
+
|
|
10
12
|
@interface RCTConvert (AirMap)
|
|
11
13
|
|
|
12
14
|
+ (MKCoordinateSpan)MKCoordinateSpan:(id)json;
|
|
@@ -16,4 +18,6 @@
|
|
|
16
18
|
+ (MKMapType)MKMapType:(id)json;
|
|
17
19
|
+ (NSDictionary*) dictonaryFromString:(NSString *) str;
|
|
18
20
|
+ (NSArray*) arrayFromString:(NSString *) str;
|
|
21
|
+
+ (NSArray<NSArray<AIRMapCoordinate *> *> *)AIRMapCoordinateArrayArray:(id)json;
|
|
22
|
+
+ (AIRMapCoordinate*) AIRMapCoordinate:(id)json;
|
|
19
23
|
@end
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
|
|
30
31
|
+ (MKMapCamera*)MKMapCamera:(id)json
|
|
31
32
|
{
|
|
32
33
|
json = [self NSDictionary:json];
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
error:&jsonError];
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
|
|
52
54
|
+ (MKMapCamera*)MKMapCameraWithDefaults:(id)json existingCamera:(MKMapCamera*)camera
|
|
53
55
|
{
|
|
54
56
|
json = [self NSDictionary:json];
|