react-native-maps 1.21.0-alpha.8 → 1.21.0-alpha.80
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 +45 -14
- 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 +18 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsGooglePolygonManagerDelegate.java +49 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsGooglePolygonManagerInterface.java +24 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerDelegate.java +206 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerInterface.java +74 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerDelegate.java +104 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerInterface.java +40 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsPolylineManagerDelegate.java +58 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsPolylineManagerInterface.java +27 -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 +27 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +29 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +940 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +809 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.cpp +170 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.h +1142 -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 +22 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +87 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.h +89 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/gradlew +1 -2
- 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 +618 -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/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/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 +30 -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/MapPolygon.java +29 -0
- 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 +1649 -1336
- package/ios/AirGoogleMaps/AIRGoogleMap.h +3 -2
- package/ios/AirGoogleMaps/AIRGoogleMap.m +155 -50
- 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.m +2 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +3 -3
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +201 -60
- 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 +5 -2
- package/ios/AirMaps/AIRMap.m +285 -153
- package/ios/AirMaps/AIRMapManager.m +6 -0
- 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/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 +340 -308
- 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 +27 -0
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +29 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.cpp +940 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.h +809 -0
- package/ios/generated/RNMapsSpecs/Props.cpp +170 -0
- package/ios/generated/RNMapsSpecs/Props.h +1142 -0
- package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +595 -0
- package/ios/generated/RNMapsSpecs/RNMapsSpecs-generated.mm +92 -0
- package/ios/generated/RNMapsSpecs/RNMapsSpecs.h +137 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +22 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.h +87 -0
- package/ios/generated/RNMapsSpecs/States.cpp +16 -0
- package/ios/generated/RNMapsSpecs/States.h +89 -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/MapCircle.d.ts +1 -1
- package/lib/MapHeatmap.d.ts +2 -2
- package/lib/MapHeatmap.js +1 -1
- package/lib/MapMarker.d.ts +16 -3
- package/lib/MapMarker.js +53 -9
- package/lib/MapMarkerNativeComponent.js +0 -2
- package/lib/MapOverlay.js +2 -8
- package/lib/MapPolygon.d.ts +1 -1
- package/lib/MapPolyline.d.ts +7 -7
- package/lib/MapView.d.ts +14 -27
- package/lib/MapView.js +97 -103
- package/lib/MapView.types.d.ts +1 -1
- package/lib/createFabricMap.d.ts +1 -0
- package/lib/createFabricMap.js +15 -2
- package/lib/decorateMapComponent.js +30 -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 +15 -15
- package/lib/specs/NativeComponentGoogleMapView.js +1 -0
- package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
- package/lib/specs/NativeComponentGooglePolygon.js +7 -0
- package/lib/specs/NativeComponentMapView.d.ts +28 -36
- package/lib/specs/NativeComponentMapView.js +2 -3
- package/lib/specs/NativeComponentMarker.d.ts +258 -0
- package/lib/specs/NativeComponentMarker.js +19 -0
- package/lib/specs/NativeComponentPolyline.d.ts +101 -0
- package/lib/specs/NativeComponentPolyline.js +7 -0
- package/package.json +25 -20
- package/react-native-maps.podspec +2 -1
package/ios/AirMaps/AIRMap.m
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
#import "AIRMapWMSTile.h"
|
|
21
21
|
#import "AIRMapLocalTile.h"
|
|
22
22
|
#import "AIRMapOverlay.h"
|
|
23
|
+
#import "AIRMapSnapshot.h"
|
|
23
24
|
|
|
24
25
|
const NSTimeInterval AIRMapRegionChangeObserveInterval = 0.1;
|
|
25
26
|
const CGFloat AIRMapZoomBoundBuffer = 0.01;
|
|
@@ -38,8 +39,6 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
38
39
|
@property (nonatomic, strong) UIActivityIndicatorView *activityIndicatorView;
|
|
39
40
|
@property (nonatomic, assign) NSNumber *shouldZoomEnabled;
|
|
40
41
|
@property (nonatomic, assign) NSNumber *shouldScrollEnabled;
|
|
41
|
-
@property (nonatomic, strong) MKCompassButton *defaultCompassButton;
|
|
42
|
-
@property (nonatomic, strong) MKCompassButton *overlayCompassButton;
|
|
43
42
|
|
|
44
43
|
- (void)updateScrollEnabled;
|
|
45
44
|
- (void)updateZoomEnabled;
|
|
@@ -50,8 +49,12 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
50
49
|
{
|
|
51
50
|
UIView *_legalLabel;
|
|
52
51
|
BOOL _initialRegionSet;
|
|
52
|
+
BOOL _initialRegionProvided;
|
|
53
|
+
BOOL _initialCameraProvided;
|
|
53
54
|
BOOL _initialCameraSet;
|
|
54
|
-
|
|
55
|
+
BOOL _initialized;
|
|
56
|
+
BOOL _loadingStarted;
|
|
57
|
+
|
|
55
58
|
// Array to manually track RN subviews
|
|
56
59
|
//
|
|
57
60
|
// AIRMap implicitly creates subviews that aren't regular RN children
|
|
@@ -69,7 +72,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
69
72
|
if ((self = [super init])) {
|
|
70
73
|
_hasStartedRendering = NO;
|
|
71
74
|
_reactSubviews = [NSMutableArray new];
|
|
72
|
-
|
|
75
|
+
|
|
73
76
|
// Find Apple link label
|
|
74
77
|
for (UIView *subview in self.subviews) {
|
|
75
78
|
if ([NSStringFromClass(subview.class) isEqualToString:@"MKAttributionLabel"]) {
|
|
@@ -79,16 +82,18 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
79
82
|
break;
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
|
-
|
|
85
|
+
|
|
83
86
|
// 3rd-party callout view for MapKit that has more options than the built-in. It's painstakingly built to
|
|
84
87
|
// be identical to the built-in callout view (which has a private API)
|
|
85
88
|
self.calloutView = [SMCalloutView platformCalloutView];
|
|
86
89
|
self.calloutView.delegate = self;
|
|
87
|
-
|
|
90
|
+
|
|
88
91
|
self.minZoom = 0;
|
|
89
92
|
self.maxZoom = AIRMapMaxZoomLevel;
|
|
90
93
|
self.compassOffset = CGPointMake(0, 0);
|
|
91
94
|
self.legacyZoomConstraintsEnabled = YES;
|
|
95
|
+
_initialized = YES;
|
|
96
|
+
[self listenToMemoryWarnings];
|
|
92
97
|
}
|
|
93
98
|
return self;
|
|
94
99
|
}
|
|
@@ -201,46 +206,25 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
201
206
|
}
|
|
202
207
|
// Create Polyline with coordinates
|
|
203
208
|
-(void) fitToCoordinates:(NSArray<AIRMapCoordinate*>*) coordinates edgePadding:(UIEdgeInsets) edgeInsets animated:(Boolean) animated {
|
|
204
|
-
CLLocationCoordinate2D coords[coordinates.count];
|
|
205
|
-
for(int i = 0; i < coordinates.count; i++)
|
|
206
|
-
{
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
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];
|
|
210
215
|
|
|
211
|
-
// Set Map viewport
|
|
216
|
+
// Set Map viewport
|
|
212
217
|
|
|
213
|
-
[self setVisibleMapRect:[polyline boundingMapRect] edgePadding:edgeInsets animated:animated];
|
|
218
|
+
[self setVisibleMapRect:[polyline boundingMapRect] edgePadding:edgeInsets animated:animated];
|
|
214
219
|
}
|
|
220
|
+
|
|
221
|
+
|
|
215
222
|
- (CGRect) frameForMarker:(AIRMapMarker*) mrkAnn {
|
|
216
223
|
MKAnnotationView* mrkView = [self viewForAnnotation: mrkAnn];
|
|
217
224
|
CGRect mrkFrame = mrkView.frame;
|
|
218
225
|
return mrkFrame;
|
|
219
226
|
}
|
|
220
227
|
|
|
221
|
-
- (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible {
|
|
222
|
-
NSMutableDictionary* markersFrames = [NSMutableDictionary new];
|
|
223
|
-
for (AIRMapMarker* mrkAnn in self.markers) {
|
|
224
|
-
CGRect frame = [self frameForMarker:mrkAnn];
|
|
225
|
-
CGPoint point = [self convertCoordinate:mrkAnn.coordinate toPointToView:self];
|
|
226
|
-
NSDictionary* frameDict = @{
|
|
227
|
-
@"x": @(frame.origin.x),
|
|
228
|
-
@"y": @(frame.origin.y),
|
|
229
|
-
@"width": @(frame.size.width),
|
|
230
|
-
@"height": @(frame.size.height)
|
|
231
|
-
};
|
|
232
|
-
NSDictionary* pointDict = @{
|
|
233
|
-
@"x": @(point.x),
|
|
234
|
-
@"y": @(point.y)
|
|
235
|
-
};
|
|
236
|
-
NSString* k = mrkAnn.identifier;
|
|
237
|
-
BOOL isVisible = CGRectIntersectsRect(self.bounds, frame);
|
|
238
|
-
if (k != nil && (!onlyVisible || isVisible)) {
|
|
239
|
-
[markersFrames setObject:@{ @"frame": frameDict, @"point": pointDict } forKey:k];
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return markersFrames;
|
|
243
|
-
}
|
|
244
228
|
|
|
245
229
|
- (AIRMapMarker*) markerAtPoint:(CGPoint)point {
|
|
246
230
|
AIRMapMarker* mrk = nil;
|
|
@@ -269,16 +253,16 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
269
253
|
// Allow touches to be sent to our calloutview.
|
|
270
254
|
// See this for some discussion of why we need to override this: https://github.com/nfarina/calloutview/pull/9
|
|
271
255
|
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
|
|
272
|
-
|
|
256
|
+
|
|
273
257
|
CGPoint touchPoint = [self.calloutView convertPoint:point fromView:self];
|
|
274
258
|
UIView *touchedView = [self.calloutView hitTest:touchPoint withEvent:event];
|
|
275
|
-
|
|
259
|
+
|
|
276
260
|
if (touchedView) {
|
|
277
261
|
UIWindow* win = [[[UIApplication sharedApplication] windows] firstObject];
|
|
278
262
|
AIRMapCalloutSubview* calloutSubview = nil;
|
|
279
263
|
AIRMapCallout* callout = nil;
|
|
280
264
|
AIRMapMarker* marker = nil;
|
|
281
|
-
|
|
265
|
+
|
|
282
266
|
UIView* tmp = touchedView;
|
|
283
267
|
while (tmp && tmp != win && tmp != self.calloutView) {
|
|
284
268
|
if ([tmp respondsToSelector:@selector(onPress)]) {
|
|
@@ -290,7 +274,7 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
290
274
|
}
|
|
291
275
|
tmp = tmp.superview;
|
|
292
276
|
}
|
|
293
|
-
|
|
277
|
+
|
|
294
278
|
if (callout) {
|
|
295
279
|
marker = [self markerForCallout:callout];
|
|
296
280
|
if (marker) {
|
|
@@ -300,49 +284,49 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
300
284
|
}
|
|
301
285
|
}
|
|
302
286
|
}
|
|
303
|
-
|
|
287
|
+
|
|
304
288
|
return calloutSubview ? calloutSubview : touchedView;
|
|
305
289
|
}
|
|
306
|
-
|
|
290
|
+
|
|
307
291
|
return [super hitTest:point withEvent:event];
|
|
308
292
|
}
|
|
309
293
|
|
|
310
294
|
#pragma mark SMCalloutViewDelegate
|
|
311
295
|
|
|
312
296
|
- (NSTimeInterval)calloutView:(SMCalloutView *)calloutView delayForRepositionWithSize:(CGSize)offset {
|
|
313
|
-
|
|
297
|
+
|
|
314
298
|
// When the callout is being asked to present in a way where it or its target will be partially offscreen, it asks us
|
|
315
299
|
// if we'd like to reposition our surface first so the callout is completely visible. Here we scroll the map into view,
|
|
316
300
|
// but it takes some math because we have to deal in lon/lat instead of the given offset in pixels.
|
|
317
|
-
|
|
301
|
+
|
|
318
302
|
CLLocationCoordinate2D coordinate = self.region.center;
|
|
319
|
-
|
|
303
|
+
|
|
320
304
|
// where's the center coordinate in terms of our view?
|
|
321
305
|
CGPoint center = [self convertCoordinate:coordinate toPointToView:self];
|
|
322
|
-
|
|
306
|
+
|
|
323
307
|
// move it by the requested offset
|
|
324
308
|
center.x -= offset.width;
|
|
325
309
|
center.y -= offset.height;
|
|
326
|
-
|
|
310
|
+
|
|
327
311
|
// and translate it back into map coordinates
|
|
328
312
|
coordinate = [self convertPoint:center toCoordinateFromView:self];
|
|
329
|
-
|
|
313
|
+
|
|
330
314
|
// move the map!
|
|
331
315
|
[self setCenterCoordinate:coordinate animated:YES];
|
|
332
|
-
|
|
316
|
+
|
|
333
317
|
// tell the callout to wait for a while while we scroll (we assume the scroll delay for MKMapView matches UIScrollView)
|
|
334
318
|
return kSMCalloutViewRepositionDelayForUIScrollView;
|
|
335
319
|
}
|
|
336
320
|
|
|
337
|
-
#pragma mark
|
|
321
|
+
#pragma mark RNMapsAirModuleDelegate.h
|
|
338
322
|
|
|
339
323
|
- (NSArray *)getMapBoundaries
|
|
340
324
|
{
|
|
341
325
|
MKMapRect mapRect = self.visibleMapRect;
|
|
342
|
-
|
|
326
|
+
|
|
343
327
|
CLLocationCoordinate2D northEast = MKCoordinateForMapPoint(MKMapPointMake(MKMapRectGetMaxX(mapRect), mapRect.origin.y));
|
|
344
328
|
CLLocationCoordinate2D southWest = MKCoordinateForMapPoint(MKMapPointMake(mapRect.origin.x, MKMapRectGetMaxY(mapRect)));
|
|
345
|
-
|
|
329
|
+
|
|
346
330
|
return @[
|
|
347
331
|
@[
|
|
348
332
|
[NSNumber numberWithDouble:northEast.longitude],
|
|
@@ -354,6 +338,174 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
354
338
|
]
|
|
355
339
|
];
|
|
356
340
|
}
|
|
341
|
+
- (NSDictionary *) getPointForCoordinates:(CLLocationCoordinate2D) location
|
|
342
|
+
{
|
|
343
|
+
CGPoint touchPoint = [self convertCoordinate:location toPointToView:self];
|
|
344
|
+
|
|
345
|
+
return @{
|
|
346
|
+
@"x": @(touchPoint.x),
|
|
347
|
+
@"y": @(touchPoint.y),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
- (NSDictionary *) getCoordinatesForPoint:(CGPoint)point
|
|
351
|
+
{
|
|
352
|
+
CLLocationCoordinate2D coordinate = [self convertPoint:point toCoordinateFromView:self];
|
|
353
|
+
return @{
|
|
354
|
+
@"latitude": @(coordinate.latitude),
|
|
355
|
+
@"longitude": @(coordinate.longitude),
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
- (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible {
|
|
361
|
+
NSMutableDictionary* markersFrames = [NSMutableDictionary new];
|
|
362
|
+
for (AIRMapMarker* mrkAnn in self.markers) {
|
|
363
|
+
CGRect frame = [self frameForMarker:mrkAnn];
|
|
364
|
+
CGPoint point = [self convertCoordinate:mrkAnn.coordinate toPointToView:self];
|
|
365
|
+
NSDictionary* frameDict = @{
|
|
366
|
+
@"x": @(frame.origin.x),
|
|
367
|
+
@"y": @(frame.origin.y),
|
|
368
|
+
@"width": @(frame.size.width),
|
|
369
|
+
@"height": @(frame.size.height)
|
|
370
|
+
};
|
|
371
|
+
NSDictionary* pointDict = @{
|
|
372
|
+
@"x": @(point.x),
|
|
373
|
+
@"y": @(point.y)
|
|
374
|
+
};
|
|
375
|
+
NSString* k = mrkAnn.identifier;
|
|
376
|
+
BOOL isVisible = CGRectIntersectsRect(self.bounds, frame);
|
|
377
|
+
if (k != nil && (!onlyVisible || isVisible)) {
|
|
378
|
+
[markersFrames setObject:@{ @"frame": frameDict, @"point": pointDict } forKey:k];
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return markersFrames;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
- (NSDictionary *) getCameraDic {
|
|
385
|
+
MKMapCamera *camera = [self camera];
|
|
386
|
+
return @{
|
|
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),
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
- (void)takeSnapshotWithConfig:(NSDictionary *)config
|
|
397
|
+
success:(RCTPromiseResolveBlock)success error:(RCTPromiseRejectBlock)error
|
|
398
|
+
{
|
|
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];
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
#pragma mark Take Snapshot
|
|
433
|
+
- (void)takeMapSnapshot:(MKMapSnapshotter *) snapshotter
|
|
434
|
+
format:(NSString *)format
|
|
435
|
+
quality:(CGFloat) quality
|
|
436
|
+
result:(NSString *)result
|
|
437
|
+
success:(RCTPromiseResolveBlock) success
|
|
438
|
+
error:(RCTPromiseRejectBlock) errorCallback {
|
|
439
|
+
NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
|
|
440
|
+
NSString *pathComponent = [NSString stringWithFormat:@"Documents/snapshot-%.20lf.%@", timeStamp, format];
|
|
441
|
+
NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent: pathComponent];
|
|
442
|
+
|
|
443
|
+
[snapshotter startWithQueue:dispatch_get_main_queue()
|
|
444
|
+
completionHandler:^(MKMapSnapshot *snapshot, NSError *error) {
|
|
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
|
+
}];
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
|
|
357
509
|
|
|
358
510
|
- (void)setShowsUserLocation:(BOOL)showsUserLocation
|
|
359
511
|
{
|
|
@@ -364,7 +516,6 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
364
516
|
|
|
365
517
|
- (void)setUserInterfaceStyle:(NSString*)userInterfaceStyle
|
|
366
518
|
{
|
|
367
|
-
if (@available(iOS 13.0, *)) {
|
|
368
519
|
if([userInterfaceStyle isEqualToString:@"light"]) {
|
|
369
520
|
self.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
|
|
370
521
|
} else if([userInterfaceStyle isEqualToString:@"dark"]) {
|
|
@@ -372,9 +523,6 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
372
523
|
} else {
|
|
373
524
|
self.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
|
|
374
525
|
}
|
|
375
|
-
} else {
|
|
376
|
-
NSLog(@"UserInterfaceStyle not supported below iOS 13");
|
|
377
|
-
}
|
|
378
526
|
}
|
|
379
527
|
|
|
380
528
|
- (void)setTintColor:(UIColor *)tintColor
|
|
@@ -392,13 +540,14 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
392
540
|
_userLocationCalloutEnabled = calloutEnabled;
|
|
393
541
|
}
|
|
394
542
|
|
|
395
|
-
- (void)setHandlePanDrag:(BOOL)
|
|
543
|
+
- (void)setHandlePanDrag:(BOOL)handlePanDrag {
|
|
396
544
|
for (UIGestureRecognizer *recognizer in [self gestureRecognizers]) {
|
|
397
545
|
if ([recognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
|
|
398
|
-
recognizer.enabled =
|
|
546
|
+
recognizer.enabled = handlePanDrag;
|
|
399
547
|
break;
|
|
400
548
|
}
|
|
401
549
|
}
|
|
550
|
+
_handlePanDrag = handlePanDrag;
|
|
402
551
|
}
|
|
403
552
|
|
|
404
553
|
- (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated
|
|
@@ -407,7 +556,7 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
407
556
|
if (!CLLocationCoordinate2DIsValid(region.center)) {
|
|
408
557
|
return;
|
|
409
558
|
}
|
|
410
|
-
|
|
559
|
+
|
|
411
560
|
// If new span values are nil, use old values instead
|
|
412
561
|
if (!region.span.latitudeDelta) {
|
|
413
562
|
region.span.latitudeDelta = self.region.span.latitudeDelta;
|
|
@@ -415,13 +564,28 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
415
564
|
if (!region.span.longitudeDelta) {
|
|
416
565
|
region.span.longitudeDelta = self.region.span.longitudeDelta;
|
|
417
566
|
}
|
|
418
|
-
|
|
567
|
+
|
|
419
568
|
// Animate/move to new position
|
|
420
569
|
[super setRegion:region animated:animated];
|
|
421
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
|
+
}
|
|
422
581
|
|
|
423
582
|
- (void)setInitialRegion:(MKCoordinateRegion)initialRegion {
|
|
424
|
-
if (!
|
|
583
|
+
if (!CLLocationCoordinate2DIsValid(initialRegion.center)) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
_initialRegion = initialRegion;
|
|
587
|
+
_initialRegionProvided = YES;
|
|
588
|
+
if (!_initialRegionSet && _loadingStarted) {
|
|
425
589
|
_initialRegionSet = YES;
|
|
426
590
|
[self setRegion:initialRegion animated:NO];
|
|
427
591
|
}
|
|
@@ -434,9 +598,13 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
434
598
|
|
|
435
599
|
|
|
436
600
|
- (void)setInitialCamera:(MKMapCamera*)initialCamera {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
601
|
+
_initialCamera = initialCamera;
|
|
602
|
+
_initialCameraProvided = YES;
|
|
603
|
+
if (initialCamera){
|
|
604
|
+
if (!_initialCameraSet && _loadingStarted) {
|
|
605
|
+
_initialCameraSet = YES;
|
|
606
|
+
[self setCamera:initialCamera animated:NO];
|
|
607
|
+
}
|
|
440
608
|
}
|
|
441
609
|
}
|
|
442
610
|
|
|
@@ -482,26 +650,24 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
482
650
|
}
|
|
483
651
|
|
|
484
652
|
- (void)setCameraZoomRange:(NSDictionary *)cameraZoomRange {
|
|
485
|
-
if (@available(iOS 13.0, *)) {
|
|
486
|
-
|
|
487
653
|
if (cameraZoomRange == nil) {
|
|
488
654
|
cameraZoomRange = @{};
|
|
489
655
|
}
|
|
490
|
-
|
|
656
|
+
|
|
491
657
|
NSNumber *minValue = cameraZoomRange[@"minCenterCoordinateDistance"];
|
|
492
658
|
NSNumber *maxValue = cameraZoomRange[@"maxCenterCoordinateDistance"];
|
|
493
|
-
|
|
659
|
+
|
|
494
660
|
if (minValue == nil && maxValue == nil) {
|
|
495
661
|
self.legacyZoomConstraintsEnabled = YES;
|
|
496
|
-
|
|
662
|
+
|
|
497
663
|
MKMapCameraZoomRange *defaultZoomRange = [[MKMapCameraZoomRange alloc] initWithMinCenterCoordinateDistance:MKMapCameraZoomDefault maxCenterCoordinateDistance:MKMapCameraZoomDefault];
|
|
498
664
|
[super setCameraZoomRange:defaultZoomRange animated:NO];
|
|
499
|
-
|
|
665
|
+
|
|
500
666
|
return;
|
|
501
667
|
}
|
|
502
|
-
|
|
668
|
+
|
|
503
669
|
MKMapCameraZoomRange *zoomRange = nil;
|
|
504
|
-
|
|
670
|
+
|
|
505
671
|
if (minValue != nil && maxValue != nil) {
|
|
506
672
|
zoomRange = [[MKMapCameraZoomRange alloc] initWithMinCenterCoordinateDistance:[minValue doubleValue] maxCenterCoordinateDistance:[maxValue doubleValue]];
|
|
507
673
|
} else if (minValue != nil) {
|
|
@@ -509,61 +675,13 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
509
675
|
} else if (maxValue != nil) {
|
|
510
676
|
zoomRange = [[MKMapCameraZoomRange alloc] initWithMaxCenterCoordinateDistance:[maxValue doubleValue]];
|
|
511
677
|
}
|
|
512
|
-
|
|
678
|
+
|
|
513
679
|
BOOL animated = [cameraZoomRange[@"animated"] boolValue];
|
|
514
|
-
|
|
680
|
+
|
|
515
681
|
self.legacyZoomConstraintsEnabled = NO;
|
|
516
682
|
[super setCameraZoomRange:zoomRange animated:animated];
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// Include properties of MKMapView which are only available on iOS 9+
|
|
521
|
-
// and check if their selector is available before calling super method.
|
|
522
|
-
|
|
523
|
-
- (void)setShowsCompass:(BOOL)showsCompass {
|
|
524
|
-
if (self.overlayCompassButton != nil) {
|
|
525
|
-
self.overlayCompassButton.compassVisibility = showsCompass ? MKFeatureVisibilityAdaptive : MKFeatureVisibilityHidden;
|
|
526
|
-
}
|
|
527
|
-
if ([MKMapView instancesRespondToSelector:@selector(setShowsCompass:)]) {
|
|
528
|
-
[super setShowsCompass:showsCompass];
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
- (BOOL)showsCompass {
|
|
533
|
-
if ([MKMapView instancesRespondToSelector:@selector(showsCompass)]) {
|
|
534
|
-
return [super showsCompass];
|
|
535
|
-
} else {
|
|
536
|
-
return NO;
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
- (void)setShowsScale:(BOOL)showsScale {
|
|
541
|
-
if ([MKMapView instancesRespondToSelector:@selector(setShowsScale:)]) {
|
|
542
|
-
[super setShowsScale:showsScale];
|
|
543
|
-
}
|
|
544
683
|
}
|
|
545
684
|
|
|
546
|
-
- (BOOL)showsScale {
|
|
547
|
-
if ([MKMapView instancesRespondToSelector:@selector(showsScale)]) {
|
|
548
|
-
return [super showsScale];
|
|
549
|
-
} else {
|
|
550
|
-
return NO;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
- (void)setShowsTraffic:(BOOL)showsTraffic {
|
|
555
|
-
if ([MKMapView instancesRespondToSelector:@selector(setShowsTraffic:)]) {
|
|
556
|
-
[super setShowsTraffic:showsTraffic];
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
- (BOOL)showsTraffic {
|
|
561
|
-
if ([MKMapView instancesRespondToSelector:@selector(showsTraffic)]) {
|
|
562
|
-
return [super showsTraffic];
|
|
563
|
-
} else {
|
|
564
|
-
return NO;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
685
|
|
|
568
686
|
- (void)setScrollEnabled:(BOOL)scrollEnabled {
|
|
569
687
|
self.shouldScrollEnabled = [NSNumber numberWithBool:scrollEnabled];
|
|
@@ -609,7 +727,7 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
609
727
|
else {
|
|
610
728
|
self.cacheImageView.image = nil;
|
|
611
729
|
self.cacheImageView.hidden = YES;
|
|
612
|
-
|
|
730
|
+
|
|
613
731
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
614
732
|
self.cacheImageView.image = nil;
|
|
615
733
|
self.cacheImageView.hidden = YES;
|
|
@@ -617,18 +735,47 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
617
735
|
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
|
|
618
736
|
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
|
|
619
737
|
UIGraphicsEndImageContext();
|
|
620
|
-
|
|
738
|
+
|
|
621
739
|
self.cacheImageView.image = image;
|
|
622
740
|
self.cacheImageView.hidden = NO;
|
|
623
741
|
});
|
|
624
742
|
}
|
|
625
|
-
|
|
743
|
+
|
|
626
744
|
[self updateScrollEnabled];
|
|
627
745
|
[self updateZoomEnabled];
|
|
628
746
|
[self updateLegalLabelInsets];
|
|
629
747
|
}
|
|
630
748
|
}
|
|
631
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
|
+
|
|
632
779
|
- (void)updateLegalLabelInsets {
|
|
633
780
|
if (_legalLabel) {
|
|
634
781
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
@@ -672,6 +819,14 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
672
819
|
self.loadingView.hidden = YES;
|
|
673
820
|
}
|
|
674
821
|
}
|
|
822
|
+
_loadingStarted = YES;
|
|
823
|
+
// display initialRegion/Camera
|
|
824
|
+
if (_initialRegionProvided){
|
|
825
|
+
[self setInitialRegion:_initialRegion];
|
|
826
|
+
}
|
|
827
|
+
if (_initialCameraProvided){
|
|
828
|
+
[self setInitialCamera:_initialCamera];
|
|
829
|
+
}
|
|
675
830
|
}
|
|
676
831
|
|
|
677
832
|
- (void)finishLoading {
|
|
@@ -718,50 +873,27 @@ MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordina
|
|
|
718
873
|
- (void)layoutSubviews {
|
|
719
874
|
[super layoutSubviews];
|
|
720
875
|
[self cacheViewIfNeeded];
|
|
721
|
-
|
|
722
|
-
if (self.overlayCompassButton == nil) {
|
|
723
|
-
for (UIView *subview in self.subviews) {
|
|
724
|
-
if (![NSStringFromClass(subview.class) isEqualToString:@"MKPassThroughStackView"]) continue;
|
|
725
|
-
self.overlayCompassButton = [MKCompassButton compassButtonWithMapView:self];
|
|
726
|
-
[subview addSubview:self.overlayCompassButton];
|
|
727
|
-
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);
|
|
728
|
-
break;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
if (self.defaultCompassButton == nil) {
|
|
733
|
-
for (UIView *subview in self.subviews) {
|
|
734
|
-
if (![NSStringFromClass(subview.class) isEqualToString:@"MKPassThroughStackView"]) continue;
|
|
735
|
-
for (UIView *subview2 in subview.subviews) {
|
|
736
|
-
if (![NSStringFromClass(subview2.class) isEqualToString:@"MKCompassView"]) continue;
|
|
737
|
-
self.defaultCompassButton = subview2;
|
|
738
|
-
self.defaultCompassButton.hidden = YES;
|
|
739
|
-
}
|
|
740
|
-
break;
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
|
|
744
876
|
}
|
|
745
877
|
|
|
746
878
|
// based on https://medium.com/@dmytrobabych/getting-actual-rotation-and-zoom-level-for-mapkit-mkmapview-e7f03f430aa9
|
|
747
879
|
- (CGFloat)getZoomLevel {
|
|
748
880
|
CGFloat cameraAngle = self.camera.heading;
|
|
749
|
-
|
|
881
|
+
|
|
750
882
|
if (cameraAngle > 270) {
|
|
751
883
|
cameraAngle = 360 - cameraAngle;
|
|
752
884
|
} else if (cameraAngle > 90) {
|
|
753
885
|
cameraAngle = fabs(cameraAngle - 180);
|
|
754
886
|
}
|
|
755
|
-
|
|
887
|
+
|
|
756
888
|
CGFloat angleRad = M_PI * cameraAngle / 180; // map rotation in radians
|
|
757
889
|
CGFloat width = self.frame.size.width;
|
|
758
890
|
CGFloat height = self.frame.size.height;
|
|
759
891
|
CGFloat heightOffset = 20; // the offset (status bar height) which is taken by MapKit into consideration to calculate visible area height
|
|
760
|
-
|
|
892
|
+
|
|
761
893
|
// calculating Longitude span corresponding to normal (non-rotated) width
|
|
762
894
|
CGFloat spanStraight = width * self.region.span.longitudeDelta / (width * cos(angleRad) + (height - heightOffset) * sin(angleRad));
|
|
763
895
|
int normalizingFactor = 512;
|
|
764
|
-
|
|
896
|
+
|
|
765
897
|
return log2(360 * ((width / normalizingFactor) / spanStraight));
|
|
766
898
|
}
|
|
767
899
|
|