react-native-maps 1.21.0-alpha.3 → 1.21.0-alpha.31
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 +14 -3
- package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +51 -0
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +46 -0
- package/ios/AirGoogleMaps/AIRGoogleMap.h +8 -2
- package/ios/AirGoogleMaps/AIRGoogleMap.m +166 -11
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +20 -11
- package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.h +13 -0
- package/ios/AirGoogleMaps/AIRGoogleMapCoordinate.m +10 -0
- package/ios/AirGoogleMaps/AIRGoogleMapManager.h +7 -0
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +30 -119
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +344 -243
- package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapOverlay.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +5 -4
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +29 -2
- package/ios/AirGoogleMaps/AIRGoogleMapPolygonManager.m +3 -3
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +3 -2
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +2 -3
- package/ios/AirGoogleMaps/AIRGoogleMapPolylineManager.m +2 -2
- 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 +18 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +26 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +599 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +25 -0
- 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 +8 -4
- package/ios/AirMaps/AIRMap.m +226 -101
- package/ios/AirMaps/AIRMapManager.m +12 -21
- package/ios/AirMaps/AIRMapMarker.h +1 -0
- package/ios/AirMaps/AIRMapMarker.m +160 -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 +3 -0
- 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 +6 -3
- package/ios/AirMaps/RNMapsMapView.mm +340 -334
- package/ios/AirMaps/RNMapsMarkerView.h +24 -0
- package/ios/AirMaps/RNMapsMarkerView.mm +404 -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/lib/MapMarker.d.ts +3 -2
- package/lib/MapMarker.js +53 -9
- package/lib/MapMarkerNativeComponent.js +0 -2
- package/lib/MapOverlay.d.ts +1 -1
- package/lib/MapView.d.ts +5 -22
- package/lib/MapView.js +34 -21
- package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -6
- package/lib/createFabricMap.js +175 -0
- package/lib/decorateMapComponent.js +18 -0
- package/lib/specs/NativeAirMapsModule.d.ts +2 -2
- package/lib/specs/NativeComponentGoogleMapView.d.ts +713 -0
- package/lib/specs/NativeComponentGoogleMapView.js +21 -0
- package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
- package/lib/specs/NativeComponentGooglePolygon.js +9 -0
- package/lib/specs/NativeComponentMapView.d.ts +21 -45
- package/lib/specs/NativeComponentMarker.d.ts +246 -0
- package/lib/specs/NativeComponentMarker.js +21 -0
- package/package.json +7 -7
- package/react-native-maps.podspec +1 -1
- package/lib/FabricMapView.js +0 -175
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;
|
|
@@ -51,6 +50,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
51
50
|
UIView *_legalLabel;
|
|
52
51
|
BOOL _initialRegionSet;
|
|
53
52
|
BOOL _initialCameraSet;
|
|
53
|
+
BOOL _initialized;
|
|
54
54
|
|
|
55
55
|
// Array to manually track RN subviews
|
|
56
56
|
//
|
|
@@ -85,10 +85,12 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
85
85
|
self.calloutView = [SMCalloutView platformCalloutView];
|
|
86
86
|
self.calloutView.delegate = self;
|
|
87
87
|
|
|
88
|
-
self.
|
|
89
|
-
self.
|
|
88
|
+
self.minZoom = 0;
|
|
89
|
+
self.maxZoom = AIRMapMaxZoomLevel;
|
|
90
90
|
self.compassOffset = CGPointMake(0, 0);
|
|
91
91
|
self.legacyZoomConstraintsEnabled = YES;
|
|
92
|
+
_initialized = YES;
|
|
93
|
+
[self listenToMemoryWarnings];
|
|
92
94
|
}
|
|
93
95
|
return self;
|
|
94
96
|
}
|
|
@@ -100,6 +102,9 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
100
102
|
[super addSubview:view];
|
|
101
103
|
}
|
|
102
104
|
}
|
|
105
|
+
- (void) didSetRegion {
|
|
106
|
+
_initialRegionSet = YES;
|
|
107
|
+
}
|
|
103
108
|
|
|
104
109
|
#pragma clang diagnostic push
|
|
105
110
|
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
@@ -199,36 +204,25 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
199
204
|
}
|
|
200
205
|
return marker;
|
|
201
206
|
}
|
|
202
|
-
|
|
207
|
+
// Create Polyline with coordinates
|
|
208
|
+
-(void) fitToCoordinates:(NSArray<AIRMapCoordinate*>*) coordinates edgePadding:(UIEdgeInsets) edgeInsets animated:(Boolean) animated {
|
|
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];
|
|
215
|
+
|
|
216
|
+
// Set Map viewport
|
|
217
|
+
|
|
218
|
+
[self setVisibleMapRect:[polyline boundingMapRect] edgePadding:edgeInsets animated:animated];
|
|
219
|
+
}
|
|
203
220
|
- (CGRect) frameForMarker:(AIRMapMarker*) mrkAnn {
|
|
204
221
|
MKAnnotationView* mrkView = [self viewForAnnotation: mrkAnn];
|
|
205
222
|
CGRect mrkFrame = mrkView.frame;
|
|
206
223
|
return mrkFrame;
|
|
207
224
|
}
|
|
208
225
|
|
|
209
|
-
- (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible {
|
|
210
|
-
NSMutableDictionary* markersFrames = [NSMutableDictionary new];
|
|
211
|
-
for (AIRMapMarker* mrkAnn in self.markers) {
|
|
212
|
-
CGRect frame = [self frameForMarker:mrkAnn];
|
|
213
|
-
CGPoint point = [self convertCoordinate:mrkAnn.coordinate toPointToView:self];
|
|
214
|
-
NSDictionary* frameDict = @{
|
|
215
|
-
@"x": @(frame.origin.x),
|
|
216
|
-
@"y": @(frame.origin.y),
|
|
217
|
-
@"width": @(frame.size.width),
|
|
218
|
-
@"height": @(frame.size.height)
|
|
219
|
-
};
|
|
220
|
-
NSDictionary* pointDict = @{
|
|
221
|
-
@"x": @(point.x),
|
|
222
|
-
@"y": @(point.y)
|
|
223
|
-
};
|
|
224
|
-
NSString* k = mrkAnn.identifier;
|
|
225
|
-
BOOL isVisible = CGRectIntersectsRect(self.bounds, frame);
|
|
226
|
-
if (k != nil && (!onlyVisible || isVisible)) {
|
|
227
|
-
[markersFrames setObject:@{ @"frame": frameDict, @"point": pointDict } forKey:k];
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return markersFrames;
|
|
231
|
-
}
|
|
232
226
|
|
|
233
227
|
- (AIRMapMarker*) markerAtPoint:(CGPoint)point {
|
|
234
228
|
AIRMapMarker* mrk = nil;
|
|
@@ -322,7 +316,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
322
316
|
return kSMCalloutViewRepositionDelayForUIScrollView;
|
|
323
317
|
}
|
|
324
318
|
|
|
325
|
-
#pragma mark
|
|
319
|
+
#pragma mark RNMapsAirModuleDelegate.h
|
|
326
320
|
|
|
327
321
|
- (NSArray *)getMapBoundaries
|
|
328
322
|
{
|
|
@@ -342,6 +336,174 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
342
336
|
]
|
|
343
337
|
];
|
|
344
338
|
}
|
|
339
|
+
- (NSDictionary *) getPointForCoordinates:(CLLocationCoordinate2D) location
|
|
340
|
+
{
|
|
341
|
+
CGPoint touchPoint = [self convertCoordinate:location toPointToView:self];
|
|
342
|
+
|
|
343
|
+
return @{
|
|
344
|
+
@"x": @(touchPoint.x),
|
|
345
|
+
@"y": @(touchPoint.y),
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
- (NSDictionary *) getCoordinatesForPoint:(CGPoint)point
|
|
349
|
+
{
|
|
350
|
+
CLLocationCoordinate2D coordinate = [self convertPoint:point toCoordinateFromView:self];
|
|
351
|
+
return @{
|
|
352
|
+
@"latitude": @(coordinate.latitude),
|
|
353
|
+
@"longitude": @(coordinate.longitude),
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
- (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible {
|
|
359
|
+
NSMutableDictionary* markersFrames = [NSMutableDictionary new];
|
|
360
|
+
for (AIRMapMarker* mrkAnn in self.markers) {
|
|
361
|
+
CGRect frame = [self frameForMarker:mrkAnn];
|
|
362
|
+
CGPoint point = [self convertCoordinate:mrkAnn.coordinate toPointToView:self];
|
|
363
|
+
NSDictionary* frameDict = @{
|
|
364
|
+
@"x": @(frame.origin.x),
|
|
365
|
+
@"y": @(frame.origin.y),
|
|
366
|
+
@"width": @(frame.size.width),
|
|
367
|
+
@"height": @(frame.size.height)
|
|
368
|
+
};
|
|
369
|
+
NSDictionary* pointDict = @{
|
|
370
|
+
@"x": @(point.x),
|
|
371
|
+
@"y": @(point.y)
|
|
372
|
+
};
|
|
373
|
+
NSString* k = mrkAnn.identifier;
|
|
374
|
+
BOOL isVisible = CGRectIntersectsRect(self.bounds, frame);
|
|
375
|
+
if (k != nil && (!onlyVisible || isVisible)) {
|
|
376
|
+
[markersFrames setObject:@{ @"frame": frameDict, @"point": pointDict } forKey:k];
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return markersFrames;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
- (NSDictionary *) getCamera {
|
|
383
|
+
MKMapCamera *camera = [self camera];
|
|
384
|
+
return @{
|
|
385
|
+
@"center": @{
|
|
386
|
+
@"latitude": @(camera.centerCoordinate.latitude),
|
|
387
|
+
@"longitude": @(camera.centerCoordinate.longitude),
|
|
388
|
+
},
|
|
389
|
+
@"pitch": @(camera.pitch),
|
|
390
|
+
@"heading": @(camera.heading),
|
|
391
|
+
@"altitude": @(camera.altitude),
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
- (void)takeSnapshotWithConfig:(NSDictionary *)config
|
|
395
|
+
success:(RCTPromiseResolveBlock)success error:(RCTPromiseRejectBlock)error
|
|
396
|
+
{
|
|
397
|
+
|
|
398
|
+
MKMapSnapshotOptions *options = [[MKMapSnapshotOptions alloc] init];
|
|
399
|
+
|
|
400
|
+
options.mapType = self.mapType;
|
|
401
|
+
NSNumber *width = config[@"width"];
|
|
402
|
+
NSNumber *height = config[@"height"];
|
|
403
|
+
NSNumber *quality = config[@"quality"];
|
|
404
|
+
NSString*format =config[@"format"];
|
|
405
|
+
NSString*result =config[@"result"];
|
|
406
|
+
if (config[@"region"]){
|
|
407
|
+
MKCoordinateRegion region = [RCTConvert MKCoordinateRegion:config[@"region"]];
|
|
408
|
+
options.region = region;
|
|
409
|
+
} else
|
|
410
|
+
{
|
|
411
|
+
options.region = self.region;
|
|
412
|
+
}
|
|
413
|
+
options.size = CGSizeMake(
|
|
414
|
+
([width floatValue] == 0) ? self.bounds.size.width : [width floatValue],
|
|
415
|
+
([height floatValue] == 0) ? self.bounds.size.height : [height floatValue]
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
options.scale = [[UIScreen mainScreen] scale];
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
MKMapSnapshotter *snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options];
|
|
422
|
+
|
|
423
|
+
[self takeMapSnapshot:snapshotter
|
|
424
|
+
format:format
|
|
425
|
+
quality:[quality floatValue]
|
|
426
|
+
result:result
|
|
427
|
+
success:success error:error];
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
#pragma mark Take Snapshot
|
|
431
|
+
- (void)takeMapSnapshot:(MKMapSnapshotter *) snapshotter
|
|
432
|
+
format:(NSString *)format
|
|
433
|
+
quality:(CGFloat) quality
|
|
434
|
+
result:(NSString *)result
|
|
435
|
+
success:(RCTPromiseResolveBlock) success
|
|
436
|
+
error:(RCTPromiseRejectBlock) errorCallback {
|
|
437
|
+
NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
|
|
438
|
+
NSString *pathComponent = [NSString stringWithFormat:@"Documents/snapshot-%.20lf.%@", timeStamp, format];
|
|
439
|
+
NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent: pathComponent];
|
|
440
|
+
|
|
441
|
+
[snapshotter startWithQueue:dispatch_get_main_queue()
|
|
442
|
+
completionHandler:^(MKMapSnapshot *snapshot, NSError *error) {
|
|
443
|
+
if (error) {
|
|
444
|
+
errorCallback(@"snapshotterError", @"failed", error);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
MKAnnotationView *pin = [[MKPinAnnotationView alloc] initWithAnnotation:nil reuseIdentifier:nil];
|
|
448
|
+
|
|
449
|
+
UIImage *image = snapshot.image;
|
|
450
|
+
UIGraphicsBeginImageContextWithOptions(image.size, YES, image.scale);
|
|
451
|
+
{
|
|
452
|
+
[image drawAtPoint:CGPointMake(0.0f, 0.0f)];
|
|
453
|
+
|
|
454
|
+
CGRect rect = CGRectMake(0.0f, 0.0f, image.size.width, image.size.height);
|
|
455
|
+
|
|
456
|
+
for (id <AIRMapSnapshot> overlay in self.overlays) {
|
|
457
|
+
if ([overlay respondsToSelector:@selector(drawToSnapshot:context:)]) {
|
|
458
|
+
[overlay drawToSnapshot:snapshot context:UIGraphicsGetCurrentContext()];
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
for (id <MKAnnotation> annotation in self.annotations) {
|
|
464
|
+
CGPoint point = [snapshot pointForCoordinate:annotation.coordinate];
|
|
465
|
+
|
|
466
|
+
MKAnnotationView* anView = [self viewForAnnotation: annotation];
|
|
467
|
+
|
|
468
|
+
if (anView){
|
|
469
|
+
pin = anView;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (CGRectContainsPoint(rect, point)) {
|
|
473
|
+
point.x = point.x + pin.centerOffset.x - (pin.bounds.size.width / 2.0f);
|
|
474
|
+
point.y = point.y + pin.centerOffset.y - (pin.bounds.size.height / 2.0f);
|
|
475
|
+
if (pin.image) {
|
|
476
|
+
[pin.image drawAtPoint:point];
|
|
477
|
+
} else {
|
|
478
|
+
CGRect pinRect = CGRectMake(point.x, point.y, pin.bounds.size.width, pin.bounds.size.height);
|
|
479
|
+
[pin drawViewHierarchyInRect:pinRect afterScreenUpdates:NO];
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
UIImage *compositeImage = UIGraphicsGetImageFromCurrentImageContext();
|
|
485
|
+
|
|
486
|
+
NSData *data;
|
|
487
|
+
if ([format isEqualToString:@"png"]) {
|
|
488
|
+
data = UIImagePNGRepresentation(compositeImage);
|
|
489
|
+
}
|
|
490
|
+
else if([format isEqualToString:@"jpg"]) {
|
|
491
|
+
data = UIImageJPEGRepresentation(compositeImage, quality);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if ([result isEqualToString:@"file"]) {
|
|
495
|
+
[data writeToFile:filePath atomically:YES];
|
|
496
|
+
success(filePath);
|
|
497
|
+
}
|
|
498
|
+
else if ([result isEqualToString:@"base64"]) {
|
|
499
|
+
success([data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
UIGraphicsEndImageContext();
|
|
503
|
+
}];
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
|
|
345
507
|
|
|
346
508
|
- (void)setShowsUserLocation:(BOOL)showsUserLocation
|
|
347
509
|
{
|
|
@@ -380,13 +542,14 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
380
542
|
_userLocationCalloutEnabled = calloutEnabled;
|
|
381
543
|
}
|
|
382
544
|
|
|
383
|
-
- (void)setHandlePanDrag:(BOOL)
|
|
545
|
+
- (void)setHandlePanDrag:(BOOL)handlePanDrag {
|
|
384
546
|
for (UIGestureRecognizer *recognizer in [self gestureRecognizers]) {
|
|
385
547
|
if ([recognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
|
|
386
|
-
recognizer.enabled =
|
|
548
|
+
recognizer.enabled = handlePanDrag;
|
|
387
549
|
break;
|
|
388
550
|
}
|
|
389
551
|
}
|
|
552
|
+
_handlePanDrag = handlePanDrag;
|
|
390
553
|
}
|
|
391
554
|
|
|
392
555
|
- (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated
|
|
@@ -409,6 +572,9 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
409
572
|
}
|
|
410
573
|
|
|
411
574
|
- (void)setInitialRegion:(MKCoordinateRegion)initialRegion {
|
|
575
|
+
if (!CLLocationCoordinate2DIsValid(initialRegion.center)) {
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
412
578
|
if (!_initialRegionSet) {
|
|
413
579
|
_initialRegionSet = YES;
|
|
414
580
|
[self setRegion:initialRegion animated:NO];
|
|
@@ -505,53 +671,6 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
505
671
|
}
|
|
506
672
|
}
|
|
507
673
|
|
|
508
|
-
// Include properties of MKMapView which are only available on iOS 9+
|
|
509
|
-
// and check if their selector is available before calling super method.
|
|
510
|
-
|
|
511
|
-
- (void)setShowsCompass:(BOOL)showsCompass {
|
|
512
|
-
if (self.overlayCompassButton != nil) {
|
|
513
|
-
self.overlayCompassButton.compassVisibility = showsCompass ? MKFeatureVisibilityAdaptive : MKFeatureVisibilityHidden;
|
|
514
|
-
}
|
|
515
|
-
if ([MKMapView instancesRespondToSelector:@selector(setShowsCompass:)]) {
|
|
516
|
-
[super setShowsCompass:showsCompass];
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
- (BOOL)showsCompass {
|
|
521
|
-
if ([MKMapView instancesRespondToSelector:@selector(showsCompass)]) {
|
|
522
|
-
return [super showsCompass];
|
|
523
|
-
} else {
|
|
524
|
-
return NO;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
- (void)setShowsScale:(BOOL)showsScale {
|
|
529
|
-
if ([MKMapView instancesRespondToSelector:@selector(setShowsScale:)]) {
|
|
530
|
-
[super setShowsScale:showsScale];
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
- (BOOL)showsScale {
|
|
535
|
-
if ([MKMapView instancesRespondToSelector:@selector(showsScale)]) {
|
|
536
|
-
return [super showsScale];
|
|
537
|
-
} else {
|
|
538
|
-
return NO;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
- (void)setShowsTraffic:(BOOL)showsTraffic {
|
|
543
|
-
if ([MKMapView instancesRespondToSelector:@selector(setShowsTraffic:)]) {
|
|
544
|
-
[super setShowsTraffic:showsTraffic];
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
- (BOOL)showsTraffic {
|
|
549
|
-
if ([MKMapView instancesRespondToSelector:@selector(showsTraffic)]) {
|
|
550
|
-
return [super showsTraffic];
|
|
551
|
-
} else {
|
|
552
|
-
return NO;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
674
|
|
|
556
675
|
- (void)setScrollEnabled:(BOOL)scrollEnabled {
|
|
557
676
|
self.shouldScrollEnabled = [NSNumber numberWithBool:scrollEnabled];
|
|
@@ -617,6 +736,35 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
617
736
|
}
|
|
618
737
|
}
|
|
619
738
|
|
|
739
|
+
- (void) listenToMemoryWarnings
|
|
740
|
+
{
|
|
741
|
+
__weak typeof(self) weakSelf = self;
|
|
742
|
+
static dispatch_once_t onceToken;
|
|
743
|
+
static dispatch_source_t source;
|
|
744
|
+
dispatch_once(&onceToken, ^{
|
|
745
|
+
source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_WARN|DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue());
|
|
746
|
+
dispatch_source_set_event_handler(source, ^{
|
|
747
|
+
[weakSelf handleMemoryWarning];
|
|
748
|
+
});
|
|
749
|
+
dispatch_resume(source);
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
/*
|
|
753
|
+
hacky way to release all cache
|
|
754
|
+
this is our last chance to release cache before app crash
|
|
755
|
+
*/
|
|
756
|
+
- (void) handleMemoryWarning
|
|
757
|
+
{
|
|
758
|
+
NSLog(@"handleMemoryWarning warning");
|
|
759
|
+
MKMapType type = self.mapType;
|
|
760
|
+
if (type == MKMapTypeSatellite){
|
|
761
|
+
self.mapType = MKMapTypeStandard;
|
|
762
|
+
} else {
|
|
763
|
+
self.mapType = MKMapTypeSatellite;
|
|
764
|
+
}
|
|
765
|
+
self.mapType = type;
|
|
766
|
+
}
|
|
767
|
+
|
|
620
768
|
- (void)updateLegalLabelInsets {
|
|
621
769
|
if (_legalLabel) {
|
|
622
770
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
@@ -706,29 +854,6 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
706
854
|
- (void)layoutSubviews {
|
|
707
855
|
[super layoutSubviews];
|
|
708
856
|
[self cacheViewIfNeeded];
|
|
709
|
-
|
|
710
|
-
if (self.overlayCompassButton == nil) {
|
|
711
|
-
for (UIView *subview in self.subviews) {
|
|
712
|
-
if (![NSStringFromClass(subview.class) isEqualToString:@"MKPassThroughStackView"]) continue;
|
|
713
|
-
self.overlayCompassButton = [MKCompassButton compassButtonWithMapView:self];
|
|
714
|
-
[subview addSubview:self.overlayCompassButton];
|
|
715
|
-
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);
|
|
716
|
-
break;
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
if (self.defaultCompassButton == nil) {
|
|
721
|
-
for (UIView *subview in self.subviews) {
|
|
722
|
-
if (![NSStringFromClass(subview.class) isEqualToString:@"MKPassThroughStackView"]) continue;
|
|
723
|
-
for (UIView *subview2 in subview.subviews) {
|
|
724
|
-
if (![NSStringFromClass(subview2.class) isEqualToString:@"MKCompassView"]) continue;
|
|
725
|
-
self.defaultCompassButton = subview2;
|
|
726
|
-
self.defaultCompassButton.hidden = YES;
|
|
727
|
-
}
|
|
728
|
-
break;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
|
|
732
857
|
}
|
|
733
858
|
|
|
734
859
|
// based on https://medium.com/@dmytrobabych/getting-actual-rotation-and-zoom-level-for-mapkit-mkmapview-e7f03f430aa9
|
|
@@ -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
|
|
@@ -1175,11 +1166,11 @@ static int kDragCenterContext;
|
|
|
1175
1166
|
|
|
1176
1167
|
CGFloat zoomLevel = [mapView getZoomLevel];
|
|
1177
1168
|
|
|
1178
|
-
if (zoomLevel < mapView.
|
|
1179
|
-
[self setCenterCoordinate:[mapView centerCoordinate] zoomLevel:mapView.
|
|
1169
|
+
if (zoomLevel < mapView.minZoom) {
|
|
1170
|
+
[self setCenterCoordinate:[mapView centerCoordinate] zoomLevel:mapView.minZoom animated:TRUE mapView:mapView];
|
|
1180
1171
|
}
|
|
1181
|
-
else if (zoomLevel > mapView.
|
|
1182
|
-
[self setCenterCoordinate:[mapView centerCoordinate] zoomLevel:mapView.
|
|
1172
|
+
else if (zoomLevel > mapView.maxZoom) {
|
|
1173
|
+
[self setCenterCoordinate:[mapView centerCoordinate] zoomLevel:mapView.maxZoom animated:TRUE mapView:mapView];
|
|
1183
1174
|
}
|
|
1184
1175
|
}
|
|
1185
1176
|
|