react-native-maps 1.21.0-alpha.13 → 1.21.0-alpha.130
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 +73 -53
- package/android/gradlew +1 -2
- package/android/src/main/RCTAppDependencyProvider.h +25 -0
- package/android/src/main/RCTAppDependencyProvider.mm +55 -0
- package/android/src/main/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/android/src/main/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/android/src/main/RCTThirdPartyComponentsProvider.h +16 -0
- package/android/src/main/RCTThirdPartyComponentsProvider.mm +28 -0
- package/android/src/main/ReactAppDependencyProvider.podspec +34 -0
- package/android/src/main/java/com/facebook/fbreact/specs/NativeAirMapsModuleSpec.java +63 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerDelegate.java +35 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerInterface.java +17 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCircleManagerDelegate.java +49 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCircleManagerInterface.java +23 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsGooglePolygonManagerDelegate.java +49 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsGooglePolygonManagerInterface.java +23 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerDelegate.java +206 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerInterface.java +73 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerDelegate.java +104 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerInterface.java +39 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerDelegate.java +46 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerInterface.java +23 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsPolylineManagerDelegate.java +58 -0
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsPolylineManagerInterface.java +26 -0
- package/android/src/main/java/com/rnmaps/fabric/CalloutManager.java +77 -0
- package/android/src/main/java/com/rnmaps/fabric/CircleManager.java +94 -0
- package/android/src/main/java/com/rnmaps/fabric/JSONUtil.java +86 -0
- package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +619 -0
- package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +258 -0
- package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +235 -2
- package/android/src/main/java/com/rnmaps/fabric/OverlayManager.java +95 -0
- package/android/src/main/java/com/rnmaps/fabric/PolygonManager.java +89 -0
- package/android/src/main/java/com/rnmaps/fabric/PolylineManager.java +121 -0
- 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/OnDoublePressEvent.java +27 -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/OnIndoorBuildingFocusedEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnIndoorLevelActivatedEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnKmlReadyEvent.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/OnPanDragEvent.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 +40 -4
- package/android/src/main/java/com/rnmaps/maps/MapCallout.java +18 -0
- package/android/src/main/java/com/rnmaps/maps/MapCircle.java +24 -0
- package/android/src/main/java/com/rnmaps/maps/MapManager.java +14 -14
- package/android/src/main/java/com/rnmaps/maps/MapMarker.java +637 -556
- package/android/src/main/java/com/rnmaps/maps/MapMarkerManager.java +3 -3
- package/android/src/main/java/com/rnmaps/maps/MapModule.java +206 -206
- package/android/src/main/java/com/rnmaps/maps/MapOverlay.java +267 -151
- package/android/src/main/java/com/rnmaps/maps/MapPolygon.java +31 -1
- package/android/src/main/java/com/rnmaps/maps/MapPolyline.java +207 -141
- package/android/src/main/java/com/rnmaps/maps/MapPolylineManager.java +1 -16
- package/android/src/main/java/com/rnmaps/maps/MapView.java +1650 -1337
- package/android/src/main/jni/CMakeLists.txt +36 -0
- package/android/src/main/jni/RNMapsSpecs-generated.cpp +68 -0
- package/android/src/main/jni/RNMapsSpecs.h +31 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +29 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +31 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +977 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +846 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.cpp +193 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.h +1223 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI-generated.cpp +74 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI.h +268 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +24 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +109 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/States.cpp +16 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/States.h +113 -0
- package/ios/AirGoogleMaps/AIRGoogleMap.h +10 -11
- package/ios/AirGoogleMaps/AIRGoogleMap.m +103 -69
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +23 -11
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +10 -9
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +6 -3
- package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +1 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +3 -0
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +0 -7
- package/ios/AirGoogleMaps/AIRGoogleMapUrlTile.m +2 -2
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +4 -4
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +1 -1
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +112 -43
- package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +16 -1
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +26 -0
- package/ios/AirMaps/AIRMap.h +8 -9
- package/ios/AirMaps/AIRMap.m +222 -239
- package/ios/AirMaps/AIRMapManager.m +10 -7
- 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/FabricPlaceholders/PlaceHolderGoogleMapView.h +28 -0
- package/ios/AirMaps/FabricPlaceholders/PlaceHolderGoogleMapView.mm +68 -0
- package/ios/AirMaps/FabricPlaceholders/PlaceHolderPolygonView.h +25 -0
- package/ios/AirMaps/FabricPlaceholders/PlaceHolderPolygonView.mm +43 -0
- package/ios/AirMaps/RNMapsAirModule.h +1 -1
- package/ios/AirMaps/RNMapsAirModule.mm +4 -3
- package/ios/AirMaps/RNMapsDefines.h +0 -0
- package/ios/AirMaps/RNMapsMapView.h +1 -1
- package/ios/AirMaps/RNMapsMapView.mm +119 -95
- package/ios/AirMaps/RNMapsMapViewManager.mm +19 -1
- package/ios/AirMaps/RNMapsMarkerView.h +24 -0
- package/ios/AirMaps/RNMapsMarkerView.mm +430 -0
- package/ios/AirMaps/RNMapsMarkerViewManager.mm +28 -0
- package/ios/AirMaps.xcodeproj/project.pbxproj +20 -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/{AirMaps → generated}/RNMapsAirModuleDelegate.h +2 -2
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +29 -0
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +31 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.cpp +977 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.h +846 -0
- package/ios/generated/RNMapsSpecs/Props.cpp +193 -0
- package/ios/generated/RNMapsSpecs/Props.h +1223 -0
- package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +591 -0
- package/ios/generated/RNMapsSpecs/RNMapsSpecs-generated.mm +92 -0
- package/ios/generated/RNMapsSpecs/RNMapsSpecs.h +137 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +24 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.h +109 -0
- package/ios/generated/RNMapsSpecs/States.cpp +16 -0
- package/ios/generated/RNMapsSpecs/States.h +113 -0
- package/ios/generated/RNMapsSpecsJSI-generated.cpp +74 -0
- package/ios/generated/RNMapsSpecsJSI.h +268 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/package.json +25 -18
- package/react-native-google-maps.podspec +26 -0
- package/react-native-maps-generated.podspec +31 -0
- package/react-native-maps.podspec +53 -15
- package/react-native.config.js +16 -0
- package/src/AnimatedRegion.ts +169 -0
- package/src/Geojson.tsx +541 -0
- package/src/MapCallout.tsx +77 -0
- package/src/MapCalloutSubview.tsx +64 -0
- package/src/MapCircle.tsx +162 -0
- package/src/MapHeatmap.tsx +125 -0
- package/src/MapLocalTile.tsx +60 -0
- package/src/MapMarker.tsx +531 -0
- package/src/MapMarkerNativeComponent.ts +51 -0
- package/src/MapOverlay.tsx +156 -0
- package/src/MapPolygon.tsx +188 -0
- package/src/MapPolygon.types.ts +25 -0
- package/src/MapPolyline.tsx +215 -0
- package/src/MapUrlTile.tsx +169 -0
- package/src/MapView.tsx +1223 -0
- package/src/MapView.types.ts +212 -0
- package/src/MapView.web.ts +2 -0
- package/src/MapViewNativeComponent.ts +86 -0
- package/src/MapWMSTile.tsx +148 -0
- package/src/ProviderConstants.ts +2 -0
- package/src/createFabricMap.tsx +253 -0
- package/src/decorateMapComponent.ts +219 -0
- package/src/fixImageProp.ts +17 -0
- package/src/index.ts +52 -0
- package/src/sharedTypes.ts +101 -0
- package/src/specs/NativeAirMapsModule.ts +36 -0
- package/src/specs/NativeComponentCallout.ts +63 -0
- package/src/specs/NativeComponentCircle.ts +93 -0
- package/src/specs/NativeComponentGoogleMapView.ts +913 -0
- package/src/specs/NativeComponentGooglePolygon.ts +94 -0
- package/src/specs/NativeComponentMapView.ts +1091 -0
- package/src/specs/NativeComponentMarker.ts +326 -0
- package/src/specs/NativeComponentOverlay.ts +89 -0
- package/src/specs/NativeComponentPolyline.ts +124 -0
- package/lib/AnimatedRegion.d.ts +0 -19
- package/lib/AnimatedRegion.js +0 -134
- package/lib/Geojson.d.ts +0 -204
- package/lib/Geojson.js +0 -166
- package/lib/MapCallout.d.ts +0 -40
- package/lib/MapCallout.js +0 -51
- package/lib/MapCalloutSubview.d.ts +0 -34
- package/lib/MapCalloutSubview.js +0 -48
- package/lib/MapCircle.d.ts +0 -117
- package/lib/MapCircle.js +0 -53
- package/lib/MapHeatmap.d.ts +0 -78
- package/lib/MapHeatmap.js +0 -59
- package/lib/MapLocalTile.d.ts +0 -35
- package/lib/MapLocalTile.js +0 -44
- package/lib/MapMarker.d.ts +0 -309
- package/lib/MapMarker.js +0 -116
- package/lib/MapMarkerNativeComponent.d.ts +0 -15
- package/lib/MapMarkerNativeComponent.js +0 -17
- package/lib/MapOverlay.d.ts +0 -87
- package/lib/MapOverlay.js +0 -63
- package/lib/MapPolygon.d.ts +0 -140
- package/lib/MapPolygon.js +0 -53
- package/lib/MapPolygon.types.d.ts +0 -18
- package/lib/MapPolygon.types.js +0 -2
- package/lib/MapPolyline.d.ts +0 -156
- package/lib/MapPolyline.js +0 -53
- package/lib/MapUrlTile.d.ts +0 -134
- package/lib/MapUrlTile.js +0 -44
- package/lib/MapView.d.ts +0 -715
- package/lib/MapView.js +0 -447
- package/lib/MapView.types.d.ts +0 -161
- package/lib/MapView.types.js +0 -2
- package/lib/MapView.web.d.ts +0 -1
- package/lib/MapView.web.js +0 -9
- package/lib/MapViewNativeComponent.d.ts +0 -18
- package/lib/MapViewNativeComponent.js +0 -19
- package/lib/MapWMSTile.d.ts +0 -116
- package/lib/MapWMSTile.js +0 -44
- package/lib/ProviderConstants.d.ts +0 -2
- package/lib/ProviderConstants.js +0 -5
- package/lib/createFabricMap.d.ts +0 -23
- package/lib/createFabricMap.js +0 -175
- package/lib/decorateMapComponent.d.ts +0 -36
- package/lib/decorateMapComponent.js +0 -80
- package/lib/index.d.ts +0 -38
- package/lib/index.js +0 -81
- package/lib/sharedTypes.d.ts +0 -81
- package/lib/sharedTypes.js +0 -2
- package/lib/sharedTypesInternal.js +0 -2
- package/lib/specs/NativeAirMapsModule.d.ts +0 -31
- package/lib/specs/NativeAirMapsModule.js +0 -4
- package/lib/specs/NativeComponentGoogleMapView.d.ts +0 -713
- package/lib/specs/NativeComponentGoogleMapView.js +0 -21
- package/lib/specs/NativeComponentMapView.d.ts +0 -855
- package/lib/specs/NativeComponentMapView.js +0 -21
- /package/ios/{AirMaps → generated}/RNMapsHostVewDelegate.h +0 -0
- /package/{lib/sharedTypesInternal.d.ts → src/sharedTypesInternal.ts} +0 -0
package/ios/AirMaps/AIRMap.m
CHANGED
|
@@ -39,8 +39,6 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
39
39
|
@property (nonatomic, strong) UIActivityIndicatorView *activityIndicatorView;
|
|
40
40
|
@property (nonatomic, assign) NSNumber *shouldZoomEnabled;
|
|
41
41
|
@property (nonatomic, assign) NSNumber *shouldScrollEnabled;
|
|
42
|
-
@property (nonatomic, strong) MKCompassButton *defaultCompassButton;
|
|
43
|
-
@property (nonatomic, strong) MKCompassButton *overlayCompassButton;
|
|
44
42
|
|
|
45
43
|
- (void)updateScrollEnabled;
|
|
46
44
|
- (void)updateZoomEnabled;
|
|
@@ -51,9 +49,12 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
51
49
|
{
|
|
52
50
|
UIView *_legalLabel;
|
|
53
51
|
BOOL _initialRegionSet;
|
|
52
|
+
BOOL _initialRegionProvided;
|
|
53
|
+
BOOL _initialCameraProvided;
|
|
54
54
|
BOOL _initialCameraSet;
|
|
55
55
|
BOOL _initialized;
|
|
56
|
-
|
|
56
|
+
BOOL _loadingStarted;
|
|
57
|
+
|
|
57
58
|
// Array to manually track RN subviews
|
|
58
59
|
//
|
|
59
60
|
// AIRMap implicitly creates subviews that aren't regular RN children
|
|
@@ -71,7 +72,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
71
72
|
if ((self = [super init])) {
|
|
72
73
|
_hasStartedRendering = NO;
|
|
73
74
|
_reactSubviews = [NSMutableArray new];
|
|
74
|
-
|
|
75
|
+
|
|
75
76
|
// Find Apple link label
|
|
76
77
|
for (UIView *subview in self.subviews) {
|
|
77
78
|
if ([NSStringFromClass(subview.class) isEqualToString:@"MKAttributionLabel"]) {
|
|
@@ -81,17 +82,18 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
81
82
|
break;
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
+
|
|
85
86
|
// 3rd-party callout view for MapKit that has more options than the built-in. It's painstakingly built to
|
|
86
87
|
// be identical to the built-in callout view (which has a private API)
|
|
87
88
|
self.calloutView = [SMCalloutView platformCalloutView];
|
|
88
89
|
self.calloutView.delegate = self;
|
|
89
|
-
|
|
90
|
+
|
|
90
91
|
self.minZoom = 0;
|
|
91
92
|
self.maxZoom = AIRMapMaxZoomLevel;
|
|
92
93
|
self.compassOffset = CGPointMake(0, 0);
|
|
93
94
|
self.legacyZoomConstraintsEnabled = YES;
|
|
94
95
|
_initialized = YES;
|
|
96
|
+
[self listenToMemoryWarnings];
|
|
95
97
|
}
|
|
96
98
|
return self;
|
|
97
99
|
}
|
|
@@ -103,9 +105,6 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
103
105
|
[super addSubview:view];
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
|
-
- (void) didSetRegion {
|
|
107
|
-
_initialRegionSet = YES;
|
|
108
|
-
}
|
|
109
108
|
|
|
110
109
|
#pragma clang diagnostic push
|
|
111
110
|
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
@@ -207,17 +206,19 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
207
206
|
}
|
|
208
207
|
// Create Polyline with coordinates
|
|
209
208
|
-(void) fitToCoordinates:(NSArray<AIRMapCoordinate*>*) coordinates edgePadding:(UIEdgeInsets) edgeInsets animated:(Boolean) animated {
|
|
210
|
-
CLLocationCoordinate2D coords[coordinates.count];
|
|
211
|
-
for(int i = 0; i < coordinates.count; i++)
|
|
212
|
-
{
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordinates.count];
|
|
209
|
+
CLLocationCoordinate2D coords[coordinates.count];
|
|
210
|
+
for(int i = 0; i < coordinates.count; i++)
|
|
211
|
+
{
|
|
212
|
+
coords[i] = coordinates[i].coordinate;
|
|
213
|
+
}
|
|
214
|
+
MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordinates.count];
|
|
216
215
|
|
|
217
|
-
// Set Map viewport
|
|
216
|
+
// Set Map viewport
|
|
218
217
|
|
|
219
|
-
[self setVisibleMapRect:[polyline boundingMapRect] edgePadding:edgeInsets animated:animated];
|
|
218
|
+
[self setVisibleMapRect:[polyline boundingMapRect] edgePadding:edgeInsets animated:animated];
|
|
220
219
|
}
|
|
220
|
+
|
|
221
|
+
|
|
221
222
|
- (CGRect) frameForMarker:(AIRMapMarker*) mrkAnn {
|
|
222
223
|
MKAnnotationView* mrkView = [self viewForAnnotation: mrkAnn];
|
|
223
224
|
CGRect mrkFrame = mrkView.frame;
|
|
@@ -252,16 +253,16 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
252
253
|
// Allow touches to be sent to our calloutview.
|
|
253
254
|
// See this for some discussion of why we need to override this: https://github.com/nfarina/calloutview/pull/9
|
|
254
255
|
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
|
|
255
|
-
|
|
256
|
+
|
|
256
257
|
CGPoint touchPoint = [self.calloutView convertPoint:point fromView:self];
|
|
257
258
|
UIView *touchedView = [self.calloutView hitTest:touchPoint withEvent:event];
|
|
258
|
-
|
|
259
|
+
|
|
259
260
|
if (touchedView) {
|
|
260
261
|
UIWindow* win = [[[UIApplication sharedApplication] windows] firstObject];
|
|
261
262
|
AIRMapCalloutSubview* calloutSubview = nil;
|
|
262
263
|
AIRMapCallout* callout = nil;
|
|
263
264
|
AIRMapMarker* marker = nil;
|
|
264
|
-
|
|
265
|
+
|
|
265
266
|
UIView* tmp = touchedView;
|
|
266
267
|
while (tmp && tmp != win && tmp != self.calloutView) {
|
|
267
268
|
if ([tmp respondsToSelector:@selector(onPress)]) {
|
|
@@ -273,7 +274,7 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
273
274
|
}
|
|
274
275
|
tmp = tmp.superview;
|
|
275
276
|
}
|
|
276
|
-
|
|
277
|
+
|
|
277
278
|
if (callout) {
|
|
278
279
|
marker = [self markerForCallout:callout];
|
|
279
280
|
if (marker) {
|
|
@@ -283,36 +284,36 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
283
284
|
}
|
|
284
285
|
}
|
|
285
286
|
}
|
|
286
|
-
|
|
287
|
+
|
|
287
288
|
return calloutSubview ? calloutSubview : touchedView;
|
|
288
289
|
}
|
|
289
|
-
|
|
290
|
+
|
|
290
291
|
return [super hitTest:point withEvent:event];
|
|
291
292
|
}
|
|
292
293
|
|
|
293
294
|
#pragma mark SMCalloutViewDelegate
|
|
294
295
|
|
|
295
296
|
- (NSTimeInterval)calloutView:(SMCalloutView *)calloutView delayForRepositionWithSize:(CGSize)offset {
|
|
296
|
-
|
|
297
|
+
|
|
297
298
|
// When the callout is being asked to present in a way where it or its target will be partially offscreen, it asks us
|
|
298
299
|
// if we'd like to reposition our surface first so the callout is completely visible. Here we scroll the map into view,
|
|
299
300
|
// but it takes some math because we have to deal in lon/lat instead of the given offset in pixels.
|
|
300
|
-
|
|
301
|
+
|
|
301
302
|
CLLocationCoordinate2D coordinate = self.region.center;
|
|
302
|
-
|
|
303
|
+
|
|
303
304
|
// where's the center coordinate in terms of our view?
|
|
304
305
|
CGPoint center = [self convertCoordinate:coordinate toPointToView:self];
|
|
305
|
-
|
|
306
|
+
|
|
306
307
|
// move it by the requested offset
|
|
307
308
|
center.x -= offset.width;
|
|
308
309
|
center.y -= offset.height;
|
|
309
|
-
|
|
310
|
+
|
|
310
311
|
// and translate it back into map coordinates
|
|
311
312
|
coordinate = [self convertPoint:center toCoordinateFromView:self];
|
|
312
|
-
|
|
313
|
+
|
|
313
314
|
// move the map!
|
|
314
315
|
[self setCenterCoordinate:coordinate animated:YES];
|
|
315
|
-
|
|
316
|
+
|
|
316
317
|
// tell the callout to wait for a while while we scroll (we assume the scroll delay for MKMapView matches UIScrollView)
|
|
317
318
|
return kSMCalloutViewRepositionDelayForUIScrollView;
|
|
318
319
|
}
|
|
@@ -322,10 +323,10 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
322
323
|
- (NSArray *)getMapBoundaries
|
|
323
324
|
{
|
|
324
325
|
MKMapRect mapRect = self.visibleMapRect;
|
|
325
|
-
|
|
326
|
+
|
|
326
327
|
CLLocationCoordinate2D northEast = MKCoordinateForMapPoint(MKMapPointMake(MKMapRectGetMaxX(mapRect), mapRect.origin.y));
|
|
327
328
|
CLLocationCoordinate2D southWest = MKCoordinateForMapPoint(MKMapPointMake(mapRect.origin.x, MKMapRectGetMaxY(mapRect)));
|
|
328
|
-
|
|
329
|
+
|
|
329
330
|
return @[
|
|
330
331
|
@[
|
|
331
332
|
[NSNumber numberWithDouble:northEast.longitude],
|
|
@@ -340,20 +341,20 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
340
341
|
- (NSDictionary *) getPointForCoordinates:(CLLocationCoordinate2D) location
|
|
341
342
|
{
|
|
342
343
|
CGPoint touchPoint = [self convertCoordinate:location toPointToView:self];
|
|
343
|
-
|
|
344
|
+
|
|
344
345
|
return @{
|
|
345
|
-
|
|
346
|
-
|
|
346
|
+
@"x": @(touchPoint.x),
|
|
347
|
+
@"y": @(touchPoint.y),
|
|
347
348
|
};
|
|
348
349
|
}
|
|
349
350
|
- (NSDictionary *) getCoordinatesForPoint:(CGPoint)point
|
|
350
351
|
{
|
|
351
352
|
CLLocationCoordinate2D coordinate = [self convertPoint:point toCoordinateFromView:self];
|
|
352
353
|
return @{
|
|
353
|
-
|
|
354
|
-
|
|
354
|
+
@"latitude": @(coordinate.latitude),
|
|
355
|
+
@"longitude": @(coordinate.longitude),
|
|
355
356
|
};
|
|
356
|
-
|
|
357
|
+
|
|
357
358
|
}
|
|
358
359
|
|
|
359
360
|
- (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible {
|
|
@@ -380,123 +381,128 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
380
381
|
return markersFrames;
|
|
381
382
|
}
|
|
382
383
|
|
|
383
|
-
- (NSDictionary *)
|
|
384
|
+
- (NSDictionary *) getCameraDic {
|
|
384
385
|
MKMapCamera *camera = [self camera];
|
|
385
386
|
return @{
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
387
|
+
@"center": @{
|
|
388
|
+
@"latitude": @(camera.centerCoordinate.latitude),
|
|
389
|
+
@"longitude": @(camera.centerCoordinate.longitude),
|
|
390
|
+
},
|
|
391
|
+
@"pitch": @(camera.pitch),
|
|
392
|
+
@"heading": @(camera.heading),
|
|
393
|
+
@"altitude": @(camera.altitude),
|
|
393
394
|
};
|
|
394
395
|
}
|
|
395
396
|
- (void)takeSnapshotWithConfig:(NSDictionary *)config
|
|
396
|
-
|
|
397
|
+
success:(RCTPromiseResolveBlock)success error:(RCTPromiseRejectBlock)error
|
|
397
398
|
{
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
399
|
+
|
|
400
|
+
MKMapSnapshotOptions *options = [[MKMapSnapshotOptions alloc] init];
|
|
401
|
+
|
|
402
|
+
options.mapType = self.mapType;
|
|
403
|
+
NSNumber *width = config[@"width"];
|
|
404
|
+
NSNumber *height = config[@"height"];
|
|
405
|
+
NSNumber *quality = config[@"quality"];
|
|
406
|
+
NSString*format =config[@"format"];
|
|
407
|
+
NSString*result =config[@"result"];
|
|
408
|
+
if (config[@"region"]){
|
|
409
|
+
MKCoordinateRegion region = [RCTConvert MKCoordinateRegion:config[@"region"]];
|
|
410
|
+
options.region = region;
|
|
411
|
+
} else
|
|
412
|
+
{
|
|
413
|
+
options.region = self.region;
|
|
414
|
+
}
|
|
415
|
+
options.size = CGSizeMake(
|
|
416
|
+
([width floatValue] == 0) ? self.bounds.size.width : [width floatValue],
|
|
417
|
+
([height floatValue] == 0) ? self.bounds.size.height : [height floatValue]
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
options.scale = [[UIScreen mainScreen] scale];
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
MKMapSnapshotter *snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options];
|
|
424
|
+
|
|
425
|
+
[self takeMapSnapshot:snapshotter
|
|
426
|
+
format:format
|
|
427
|
+
quality:[quality floatValue]
|
|
428
|
+
result:result
|
|
429
|
+
success:success error:error];
|
|
426
430
|
}
|
|
427
431
|
|
|
428
432
|
#pragma mark Take Snapshot
|
|
429
433
|
- (void)takeMapSnapshot:(MKMapSnapshotter *) snapshotter
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
+
format:(NSString *)format
|
|
435
|
+
quality:(CGFloat) quality
|
|
436
|
+
result:(NSString *)result
|
|
437
|
+
success:(RCTPromiseResolveBlock) success
|
|
438
|
+
error:(RCTPromiseRejectBlock) errorCallback {
|
|
434
439
|
NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
|
|
435
440
|
NSString *pathComponent = [NSString stringWithFormat:@"Documents/snapshot-%.20lf.%@", timeStamp, format];
|
|
436
441
|
NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent: pathComponent];
|
|
437
442
|
|
|
438
443
|
[snapshotter startWithQueue:dispatch_get_main_queue()
|
|
439
444
|
completionHandler:^(MKMapSnapshot *snapshot, NSError *error) {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
445
|
+
if (error) {
|
|
446
|
+
errorCallback(@"snapshotterError", @"failed", error);
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
MKAnnotationView *pin = [[MKPinAnnotationView alloc] initWithAnnotation:nil reuseIdentifier:nil];
|
|
450
|
+
|
|
451
|
+
UIImage *image = snapshot.image;
|
|
452
|
+
UIGraphicsBeginImageContextWithOptions(image.size, YES, image.scale);
|
|
453
|
+
{
|
|
454
|
+
[image drawAtPoint:CGPointMake(0.0f, 0.0f)];
|
|
455
|
+
|
|
456
|
+
CGRect rect = CGRectMake(0.0f, 0.0f, image.size.width, image.size.height);
|
|
457
|
+
|
|
458
|
+
for (id <AIRMapSnapshot> overlay in self.overlays) {
|
|
459
|
+
if ([overlay respondsToSelector:@selector(drawToSnapshot:context:)]) {
|
|
460
|
+
[overlay drawToSnapshot:snapshot context:UIGraphicsGetCurrentContext()];
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
for (id <MKAnnotation> annotation in self.annotations) {
|
|
466
|
+
CGPoint point = [snapshot pointForCoordinate:annotation.coordinate];
|
|
467
|
+
|
|
468
|
+
MKAnnotationView* anView = [self viewForAnnotation: annotation];
|
|
469
|
+
|
|
470
|
+
if (anView){
|
|
471
|
+
pin = anView;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
if (CGRectContainsPoint(rect, point)) {
|
|
475
|
+
point.x = point.x + pin.centerOffset.x - (pin.bounds.size.width / 2.0f);
|
|
476
|
+
point.y = point.y + pin.centerOffset.y - (pin.bounds.size.height / 2.0f);
|
|
477
|
+
if (pin.image) {
|
|
478
|
+
[pin.image drawAtPoint:point];
|
|
479
|
+
} else {
|
|
480
|
+
CGRect pinRect = CGRectMake(point.x, point.y, pin.bounds.size.width, pin.bounds.size.height);
|
|
481
|
+
[pin drawViewHierarchyInRect:pinRect afterScreenUpdates:NO];
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
UIImage *compositeImage = UIGraphicsGetImageFromCurrentImageContext();
|
|
487
|
+
|
|
488
|
+
NSData *data;
|
|
489
|
+
if ([format isEqualToString:@"png"]) {
|
|
490
|
+
data = UIImagePNGRepresentation(compositeImage);
|
|
491
|
+
}
|
|
492
|
+
else if([format isEqualToString:@"jpg"]) {
|
|
493
|
+
data = UIImageJPEGRepresentation(compositeImage, quality);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if ([result isEqualToString:@"file"]) {
|
|
497
|
+
[data writeToFile:filePath atomically:YES];
|
|
498
|
+
success(filePath);
|
|
499
|
+
}
|
|
500
|
+
else if ([result isEqualToString:@"base64"]) {
|
|
501
|
+
success([data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
UIGraphicsEndImageContext();
|
|
505
|
+
}];
|
|
500
506
|
}
|
|
501
507
|
|
|
502
508
|
|
|
@@ -510,7 +516,6 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
510
516
|
|
|
511
517
|
- (void)setUserInterfaceStyle:(NSString*)userInterfaceStyle
|
|
512
518
|
{
|
|
513
|
-
if (@available(iOS 13.0, *)) {
|
|
514
519
|
if([userInterfaceStyle isEqualToString:@"light"]) {
|
|
515
520
|
self.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
|
|
516
521
|
} else if([userInterfaceStyle isEqualToString:@"dark"]) {
|
|
@@ -518,9 +523,6 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
518
523
|
} else {
|
|
519
524
|
self.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
|
|
520
525
|
}
|
|
521
|
-
} else {
|
|
522
|
-
NSLog(@"UserInterfaceStyle not supported below iOS 13");
|
|
523
|
-
}
|
|
524
526
|
}
|
|
525
527
|
|
|
526
528
|
- (void)setTintColor:(UIColor *)tintColor
|
|
@@ -538,13 +540,14 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
538
540
|
_userLocationCalloutEnabled = calloutEnabled;
|
|
539
541
|
}
|
|
540
542
|
|
|
541
|
-
- (void)setHandlePanDrag:(BOOL)
|
|
543
|
+
- (void)setHandlePanDrag:(BOOL)handlePanDrag {
|
|
542
544
|
for (UIGestureRecognizer *recognizer in [self gestureRecognizers]) {
|
|
543
545
|
if ([recognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
|
|
544
|
-
recognizer.enabled =
|
|
546
|
+
recognizer.enabled = handlePanDrag;
|
|
545
547
|
break;
|
|
546
548
|
}
|
|
547
549
|
}
|
|
550
|
+
_handlePanDrag = handlePanDrag;
|
|
548
551
|
}
|
|
549
552
|
|
|
550
553
|
- (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated
|
|
@@ -553,7 +556,7 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
553
556
|
if (!CLLocationCoordinate2DIsValid(region.center)) {
|
|
554
557
|
return;
|
|
555
558
|
}
|
|
556
|
-
|
|
559
|
+
|
|
557
560
|
// If new span values are nil, use old values instead
|
|
558
561
|
if (!region.span.latitudeDelta) {
|
|
559
562
|
region.span.latitudeDelta = self.region.span.latitudeDelta;
|
|
@@ -561,16 +564,28 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
561
564
|
if (!region.span.longitudeDelta) {
|
|
562
565
|
region.span.longitudeDelta = self.region.span.longitudeDelta;
|
|
563
566
|
}
|
|
564
|
-
|
|
567
|
+
|
|
565
568
|
// Animate/move to new position
|
|
566
569
|
[super setRegion:region animated:animated];
|
|
567
570
|
}
|
|
571
|
+
- (void) setRegion:(MKCoordinateRegion)region
|
|
572
|
+
{
|
|
573
|
+
if (!CLLocationCoordinate2DIsValid(region.center)) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
if (!CLLocationCoordinate2DIsValid(_initialRegion.center)) {
|
|
577
|
+
[self setInitialRegion:region];
|
|
578
|
+
}
|
|
579
|
+
[self setRegion:region animated:NO];
|
|
580
|
+
}
|
|
568
581
|
|
|
569
582
|
- (void)setInitialRegion:(MKCoordinateRegion)initialRegion {
|
|
570
583
|
if (!CLLocationCoordinate2DIsValid(initialRegion.center)) {
|
|
571
584
|
return;
|
|
572
585
|
}
|
|
573
|
-
|
|
586
|
+
_initialRegion = initialRegion;
|
|
587
|
+
_initialRegionProvided = YES;
|
|
588
|
+
if (!_initialRegionSet && _loadingStarted) {
|
|
574
589
|
_initialRegionSet = YES;
|
|
575
590
|
[self setRegion:initialRegion animated:NO];
|
|
576
591
|
}
|
|
@@ -583,9 +598,13 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
583
598
|
|
|
584
599
|
|
|
585
600
|
- (void)setInitialCamera:(MKMapCamera*)initialCamera {
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
601
|
+
_initialCamera = initialCamera;
|
|
602
|
+
_initialCameraProvided = YES;
|
|
603
|
+
if (initialCamera){
|
|
604
|
+
if (!_initialCameraSet && _loadingStarted) {
|
|
605
|
+
_initialCameraSet = YES;
|
|
606
|
+
[self setCamera:initialCamera animated:NO];
|
|
607
|
+
}
|
|
589
608
|
}
|
|
590
609
|
}
|
|
591
610
|
|
|
@@ -631,26 +650,24 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
631
650
|
}
|
|
632
651
|
|
|
633
652
|
- (void)setCameraZoomRange:(NSDictionary *)cameraZoomRange {
|
|
634
|
-
if (@available(iOS 13.0, *)) {
|
|
635
|
-
|
|
636
653
|
if (cameraZoomRange == nil) {
|
|
637
654
|
cameraZoomRange = @{};
|
|
638
655
|
}
|
|
639
|
-
|
|
656
|
+
|
|
640
657
|
NSNumber *minValue = cameraZoomRange[@"minCenterCoordinateDistance"];
|
|
641
658
|
NSNumber *maxValue = cameraZoomRange[@"maxCenterCoordinateDistance"];
|
|
642
|
-
|
|
659
|
+
|
|
643
660
|
if (minValue == nil && maxValue == nil) {
|
|
644
661
|
self.legacyZoomConstraintsEnabled = YES;
|
|
645
|
-
|
|
662
|
+
|
|
646
663
|
MKMapCameraZoomRange *defaultZoomRange = [[MKMapCameraZoomRange alloc] initWithMinCenterCoordinateDistance:MKMapCameraZoomDefault maxCenterCoordinateDistance:MKMapCameraZoomDefault];
|
|
647
664
|
[super setCameraZoomRange:defaultZoomRange animated:NO];
|
|
648
|
-
|
|
665
|
+
|
|
649
666
|
return;
|
|
650
667
|
}
|
|
651
|
-
|
|
668
|
+
|
|
652
669
|
MKMapCameraZoomRange *zoomRange = nil;
|
|
653
|
-
|
|
670
|
+
|
|
654
671
|
if (minValue != nil && maxValue != nil) {
|
|
655
672
|
zoomRange = [[MKMapCameraZoomRange alloc] initWithMinCenterCoordinateDistance:[minValue doubleValue] maxCenterCoordinateDistance:[maxValue doubleValue]];
|
|
656
673
|
} else if (minValue != nil) {
|
|
@@ -658,61 +675,13 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
658
675
|
} else if (maxValue != nil) {
|
|
659
676
|
zoomRange = [[MKMapCameraZoomRange alloc] initWithMaxCenterCoordinateDistance:[maxValue doubleValue]];
|
|
660
677
|
}
|
|
661
|
-
|
|
678
|
+
|
|
662
679
|
BOOL animated = [cameraZoomRange[@"animated"] boolValue];
|
|
663
|
-
|
|
680
|
+
|
|
664
681
|
self.legacyZoomConstraintsEnabled = NO;
|
|
665
682
|
[super setCameraZoomRange:zoomRange animated:animated];
|
|
666
|
-
}
|
|
667
683
|
}
|
|
668
684
|
|
|
669
|
-
// Include properties of MKMapView which are only available on iOS 9+
|
|
670
|
-
// and check if their selector is available before calling super method.
|
|
671
|
-
|
|
672
|
-
- (void)setShowsCompass:(BOOL)showsCompass {
|
|
673
|
-
if (self.overlayCompassButton != nil) {
|
|
674
|
-
self.overlayCompassButton.compassVisibility = showsCompass ? MKFeatureVisibilityAdaptive : MKFeatureVisibilityHidden;
|
|
675
|
-
}
|
|
676
|
-
if ([MKMapView instancesRespondToSelector:@selector(setShowsCompass:)]) {
|
|
677
|
-
[super setShowsCompass:showsCompass];
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
- (BOOL)showsCompass {
|
|
682
|
-
if ([MKMapView instancesRespondToSelector:@selector(showsCompass)]) {
|
|
683
|
-
return [super showsCompass];
|
|
684
|
-
} else {
|
|
685
|
-
return NO;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
- (void)setShowsScale:(BOOL)showsScale {
|
|
690
|
-
if ([MKMapView instancesRespondToSelector:@selector(setShowsScale:)]) {
|
|
691
|
-
[super setShowsScale:showsScale];
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
- (BOOL)showsScale {
|
|
696
|
-
if ([MKMapView instancesRespondToSelector:@selector(showsScale)]) {
|
|
697
|
-
return [super showsScale];
|
|
698
|
-
} else {
|
|
699
|
-
return NO;
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
- (void)setShowsTraffic:(BOOL)showsTraffic {
|
|
704
|
-
if ([MKMapView instancesRespondToSelector:@selector(setShowsTraffic:)]) {
|
|
705
|
-
[super setShowsTraffic:showsTraffic];
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
- (BOOL)showsTraffic {
|
|
710
|
-
if ([MKMapView instancesRespondToSelector:@selector(showsTraffic)]) {
|
|
711
|
-
return [super showsTraffic];
|
|
712
|
-
} else {
|
|
713
|
-
return NO;
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
685
|
|
|
717
686
|
- (void)setScrollEnabled:(BOOL)scrollEnabled {
|
|
718
687
|
self.shouldScrollEnabled = [NSNumber numberWithBool:scrollEnabled];
|
|
@@ -758,7 +727,7 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
758
727
|
else {
|
|
759
728
|
self.cacheImageView.image = nil;
|
|
760
729
|
self.cacheImageView.hidden = YES;
|
|
761
|
-
|
|
730
|
+
|
|
762
731
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
763
732
|
self.cacheImageView.image = nil;
|
|
764
733
|
self.cacheImageView.hidden = YES;
|
|
@@ -766,18 +735,47 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
766
735
|
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
|
|
767
736
|
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
|
|
768
737
|
UIGraphicsEndImageContext();
|
|
769
|
-
|
|
738
|
+
|
|
770
739
|
self.cacheImageView.image = image;
|
|
771
740
|
self.cacheImageView.hidden = NO;
|
|
772
741
|
});
|
|
773
742
|
}
|
|
774
|
-
|
|
743
|
+
|
|
775
744
|
[self updateScrollEnabled];
|
|
776
745
|
[self updateZoomEnabled];
|
|
777
746
|
[self updateLegalLabelInsets];
|
|
778
747
|
}
|
|
779
748
|
}
|
|
780
749
|
|
|
750
|
+
- (void) listenToMemoryWarnings
|
|
751
|
+
{
|
|
752
|
+
__weak typeof(self) weakSelf = self;
|
|
753
|
+
static dispatch_once_t onceToken;
|
|
754
|
+
static dispatch_source_t source;
|
|
755
|
+
dispatch_once(&onceToken, ^{
|
|
756
|
+
source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_WARN|DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue());
|
|
757
|
+
dispatch_source_set_event_handler(source, ^{
|
|
758
|
+
[weakSelf handleMemoryWarning];
|
|
759
|
+
});
|
|
760
|
+
dispatch_resume(source);
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
/*
|
|
764
|
+
hacky way to release all cache
|
|
765
|
+
this is our last chance to release cache before app crash
|
|
766
|
+
*/
|
|
767
|
+
- (void) handleMemoryWarning
|
|
768
|
+
{
|
|
769
|
+
NSLog(@"handleMemoryWarning warning");
|
|
770
|
+
MKMapType type = self.mapType;
|
|
771
|
+
if (type == MKMapTypeSatellite){
|
|
772
|
+
self.mapType = MKMapTypeStandard;
|
|
773
|
+
} else {
|
|
774
|
+
self.mapType = MKMapTypeSatellite;
|
|
775
|
+
}
|
|
776
|
+
self.mapType = type;
|
|
777
|
+
}
|
|
778
|
+
|
|
781
779
|
- (void)updateLegalLabelInsets {
|
|
782
780
|
if (_legalLabel) {
|
|
783
781
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
@@ -821,6 +819,14 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
821
819
|
self.loadingView.hidden = YES;
|
|
822
820
|
}
|
|
823
821
|
}
|
|
822
|
+
_loadingStarted = YES;
|
|
823
|
+
// display initialRegion/Camera
|
|
824
|
+
if (_initialRegionProvided){
|
|
825
|
+
[self setInitialRegion:_initialRegion];
|
|
826
|
+
}
|
|
827
|
+
if (_initialCameraProvided){
|
|
828
|
+
[self setInitialCamera:_initialCamera];
|
|
829
|
+
}
|
|
824
830
|
}
|
|
825
831
|
|
|
826
832
|
- (void)finishLoading {
|
|
@@ -867,50 +873,27 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
867
873
|
- (void)layoutSubviews {
|
|
868
874
|
[super layoutSubviews];
|
|
869
875
|
[self cacheViewIfNeeded];
|
|
870
|
-
|
|
871
|
-
if (self.overlayCompassButton == nil) {
|
|
872
|
-
for (UIView *subview in self.subviews) {
|
|
873
|
-
if (![NSStringFromClass(subview.class) isEqualToString:@"MKPassThroughStackView"]) continue;
|
|
874
|
-
self.overlayCompassButton = [MKCompassButton compassButtonWithMapView:self];
|
|
875
|
-
[subview addSubview:self.overlayCompassButton];
|
|
876
|
-
self.overlayCompassButton.frame = CGRectMake(self.overlayCompassButton.frame.origin.x + _compassOffset.x, self.overlayCompassButton.frame.origin.y + _compassOffset.y, self.overlayCompassButton.frame.size.width, self.overlayCompassButton.frame.size.height);
|
|
877
|
-
break;
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
if (self.defaultCompassButton == nil) {
|
|
882
|
-
for (UIView *subview in self.subviews) {
|
|
883
|
-
if (![NSStringFromClass(subview.class) isEqualToString:@"MKPassThroughStackView"]) continue;
|
|
884
|
-
for (UIView *subview2 in subview.subviews) {
|
|
885
|
-
if (![NSStringFromClass(subview2.class) isEqualToString:@"MKCompassView"]) continue;
|
|
886
|
-
self.defaultCompassButton = subview2;
|
|
887
|
-
self.defaultCompassButton.hidden = YES;
|
|
888
|
-
}
|
|
889
|
-
break;
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
|
|
893
876
|
}
|
|
894
877
|
|
|
895
878
|
// based on https://medium.com/@dmytrobabych/getting-actual-rotation-and-zoom-level-for-mapkit-mkmapview-e7f03f430aa9
|
|
896
879
|
- (CGFloat)getZoomLevel {
|
|
897
880
|
CGFloat cameraAngle = self.camera.heading;
|
|
898
|
-
|
|
881
|
+
|
|
899
882
|
if (cameraAngle > 270) {
|
|
900
883
|
cameraAngle = 360 - cameraAngle;
|
|
901
884
|
} else if (cameraAngle > 90) {
|
|
902
885
|
cameraAngle = fabs(cameraAngle - 180);
|
|
903
886
|
}
|
|
904
|
-
|
|
887
|
+
|
|
905
888
|
CGFloat angleRad = M_PI * cameraAngle / 180; // map rotation in radians
|
|
906
889
|
CGFloat width = self.frame.size.width;
|
|
907
890
|
CGFloat height = self.frame.size.height;
|
|
908
891
|
CGFloat heightOffset = 20; // the offset (status bar height) which is taken by MapKit into consideration to calculate visible area height
|
|
909
|
-
|
|
892
|
+
|
|
910
893
|
// calculating Longitude span corresponding to normal (non-rotated) width
|
|
911
894
|
CGFloat spanStraight = width * self.region.span.longitudeDelta / (width * cos(angleRad) + (height - heightOffset) * sin(angleRad));
|
|
912
895
|
int normalizingFactor = 512;
|
|
913
|
-
|
|
896
|
+
|
|
914
897
|
return log2(360 * ((width / normalizingFactor) / spanStraight));
|
|
915
898
|
}
|
|
916
899
|
|