react-native-maps 1.21.0-alpha.32 → 1.21.0-alpha.33

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.
@@ -51,7 +51,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
51
51
  BOOL _initialRegionSet;
52
52
  BOOL _initialCameraSet;
53
53
  BOOL _initialized;
54
-
54
+
55
55
  // Array to manually track RN subviews
56
56
  //
57
57
  // AIRMap implicitly creates subviews that aren't regular RN children
@@ -69,7 +69,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
69
69
  if ((self = [super init])) {
70
70
  _hasStartedRendering = NO;
71
71
  _reactSubviews = [NSMutableArray new];
72
-
72
+
73
73
  // Find Apple link label
74
74
  for (UIView *subview in self.subviews) {
75
75
  if ([NSStringFromClass(subview.class) isEqualToString:@"MKAttributionLabel"]) {
@@ -79,12 +79,12 @@ const NSInteger AIRMapMaxZoomLevel = 20;
79
79
  break;
80
80
  }
81
81
  }
82
-
82
+
83
83
  // 3rd-party callout view for MapKit that has more options than the built-in. It's painstakingly built to
84
84
  // be identical to the built-in callout view (which has a private API)
85
85
  self.calloutView = [SMCalloutView platformCalloutView];
86
86
  self.calloutView.delegate = self;
87
-
87
+
88
88
  self.minZoom = 0;
89
89
  self.maxZoom = AIRMapMaxZoomLevel;
90
90
  self.compassOffset = CGPointMake(0, 0);
@@ -212,11 +212,13 @@ const NSInteger AIRMapMaxZoomLevel = 20;
212
212
  coords[i] = coordinates[i].coordinate;
213
213
  }
214
214
  MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coords count:coordinates.count];
215
-
215
+
216
216
  // Set Map viewport
217
-
217
+
218
218
  [self setVisibleMapRect:[polyline boundingMapRect] edgePadding:edgeInsets animated:animated];
219
219
  }
220
+
221
+
220
222
  - (CGRect) frameForMarker:(AIRMapMarker*) mrkAnn {
221
223
  MKAnnotationView* mrkView = [self viewForAnnotation: mrkAnn];
222
224
  CGRect mrkFrame = mrkView.frame;
@@ -251,16 +253,16 @@ const NSInteger AIRMapMaxZoomLevel = 20;
251
253
  // Allow touches to be sent to our calloutview.
252
254
  // See this for some discussion of why we need to override this: https://github.com/nfarina/calloutview/pull/9
253
255
  - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
254
-
256
+
255
257
  CGPoint touchPoint = [self.calloutView convertPoint:point fromView:self];
256
258
  UIView *touchedView = [self.calloutView hitTest:touchPoint withEvent:event];
257
-
259
+
258
260
  if (touchedView) {
259
261
  UIWindow* win = [[[UIApplication sharedApplication] windows] firstObject];
260
262
  AIRMapCalloutSubview* calloutSubview = nil;
261
263
  AIRMapCallout* callout = nil;
262
264
  AIRMapMarker* marker = nil;
263
-
265
+
264
266
  UIView* tmp = touchedView;
265
267
  while (tmp && tmp != win && tmp != self.calloutView) {
266
268
  if ([tmp respondsToSelector:@selector(onPress)]) {
@@ -272,7 +274,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
272
274
  }
273
275
  tmp = tmp.superview;
274
276
  }
275
-
277
+
276
278
  if (callout) {
277
279
  marker = [self markerForCallout:callout];
278
280
  if (marker) {
@@ -282,36 +284,36 @@ const NSInteger AIRMapMaxZoomLevel = 20;
282
284
  }
283
285
  }
284
286
  }
285
-
287
+
286
288
  return calloutSubview ? calloutSubview : touchedView;
287
289
  }
288
-
290
+
289
291
  return [super hitTest:point withEvent:event];
290
292
  }
291
293
 
292
294
  #pragma mark SMCalloutViewDelegate
293
295
 
294
296
  - (NSTimeInterval)calloutView:(SMCalloutView *)calloutView delayForRepositionWithSize:(CGSize)offset {
295
-
297
+
296
298
  // When the callout is being asked to present in a way where it or its target will be partially offscreen, it asks us
297
299
  // if we'd like to reposition our surface first so the callout is completely visible. Here we scroll the map into view,
298
300
  // but it takes some math because we have to deal in lon/lat instead of the given offset in pixels.
299
-
301
+
300
302
  CLLocationCoordinate2D coordinate = self.region.center;
301
-
303
+
302
304
  // where's the center coordinate in terms of our view?
303
305
  CGPoint center = [self convertCoordinate:coordinate toPointToView:self];
304
-
306
+
305
307
  // move it by the requested offset
306
308
  center.x -= offset.width;
307
309
  center.y -= offset.height;
308
-
310
+
309
311
  // and translate it back into map coordinates
310
312
  coordinate = [self convertPoint:center toCoordinateFromView:self];
311
-
313
+
312
314
  // move the map!
313
315
  [self setCenterCoordinate:coordinate animated:YES];
314
-
316
+
315
317
  // tell the callout to wait for a while while we scroll (we assume the scroll delay for MKMapView matches UIScrollView)
316
318
  return kSMCalloutViewRepositionDelayForUIScrollView;
317
319
  }
@@ -321,10 +323,10 @@ const NSInteger AIRMapMaxZoomLevel = 20;
321
323
  - (NSArray *)getMapBoundaries
322
324
  {
323
325
  MKMapRect mapRect = self.visibleMapRect;
324
-
326
+
325
327
  CLLocationCoordinate2D northEast = MKCoordinateForMapPoint(MKMapPointMake(MKMapRectGetMaxX(mapRect), mapRect.origin.y));
326
328
  CLLocationCoordinate2D southWest = MKCoordinateForMapPoint(MKMapPointMake(mapRect.origin.x, MKMapRectGetMaxY(mapRect)));
327
-
329
+
328
330
  return @[
329
331
  @[
330
332
  [NSNumber numberWithDouble:northEast.longitude],
@@ -339,7 +341,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
339
341
  - (NSDictionary *) getPointForCoordinates:(CLLocationCoordinate2D) location
340
342
  {
341
343
  CGPoint touchPoint = [self convertCoordinate:location toPointToView:self];
342
-
344
+
343
345
  return @{
344
346
  @"x": @(touchPoint.x),
345
347
  @"y": @(touchPoint.y),
@@ -352,7 +354,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
352
354
  @"latitude": @(coordinate.latitude),
353
355
  @"longitude": @(coordinate.longitude),
354
356
  };
355
-
357
+
356
358
  }
357
359
 
358
360
  - (NSDictionary*) getMarkersFramesWithOnlyVisible:(BOOL)onlyVisible {
@@ -394,9 +396,9 @@ const NSInteger AIRMapMaxZoomLevel = 20;
394
396
  - (void)takeSnapshotWithConfig:(NSDictionary *)config
395
397
  success:(RCTPromiseResolveBlock)success error:(RCTPromiseRejectBlock)error
396
398
  {
397
-
399
+
398
400
  MKMapSnapshotOptions *options = [[MKMapSnapshotOptions alloc] init];
399
-
401
+
400
402
  options.mapType = self.mapType;
401
403
  NSNumber *width = config[@"width"];
402
404
  NSNumber *height = config[@"height"];
@@ -414,12 +416,12 @@ const NSInteger AIRMapMaxZoomLevel = 20;
414
416
  ([width floatValue] == 0) ? self.bounds.size.width : [width floatValue],
415
417
  ([height floatValue] == 0) ? self.bounds.size.height : [height floatValue]
416
418
  );
417
-
419
+
418
420
  options.scale = [[UIScreen mainScreen] scale];
419
-
420
-
421
+
422
+
421
423
  MKMapSnapshotter *snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options];
422
-
424
+
423
425
  [self takeMapSnapshot:snapshotter
424
426
  format:format
425
427
  quality:[quality floatValue]
@@ -437,7 +439,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
437
439
  NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
438
440
  NSString *pathComponent = [NSString stringWithFormat:@"Documents/snapshot-%.20lf.%@", timeStamp, format];
439
441
  NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent: pathComponent];
440
-
442
+
441
443
  [snapshotter startWithQueue:dispatch_get_main_queue()
442
444
  completionHandler:^(MKMapSnapshot *snapshot, NSError *error) {
443
445
  if (error) {
@@ -445,30 +447,30 @@ const NSInteger AIRMapMaxZoomLevel = 20;
445
447
  return;
446
448
  }
447
449
  MKAnnotationView *pin = [[MKPinAnnotationView alloc] initWithAnnotation:nil reuseIdentifier:nil];
448
-
450
+
449
451
  UIImage *image = snapshot.image;
450
452
  UIGraphicsBeginImageContextWithOptions(image.size, YES, image.scale);
451
453
  {
452
454
  [image drawAtPoint:CGPointMake(0.0f, 0.0f)];
453
-
455
+
454
456
  CGRect rect = CGRectMake(0.0f, 0.0f, image.size.width, image.size.height);
455
-
457
+
456
458
  for (id <AIRMapSnapshot> overlay in self.overlays) {
457
459
  if ([overlay respondsToSelector:@selector(drawToSnapshot:context:)]) {
458
460
  [overlay drawToSnapshot:snapshot context:UIGraphicsGetCurrentContext()];
459
461
  }
460
462
  }
461
463
 
462
-
464
+
463
465
  for (id <MKAnnotation> annotation in self.annotations) {
464
466
  CGPoint point = [snapshot pointForCoordinate:annotation.coordinate];
465
-
467
+
466
468
  MKAnnotationView* anView = [self viewForAnnotation: annotation];
467
-
469
+
468
470
  if (anView){
469
471
  pin = anView;
470
472
  }
471
-
473
+
472
474
  if (CGRectContainsPoint(rect, point)) {
473
475
  point.x = point.x + pin.centerOffset.x - (pin.bounds.size.width / 2.0f);
474
476
  point.y = point.y + pin.centerOffset.y - (pin.bounds.size.height / 2.0f);
@@ -490,7 +492,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
490
492
  else if([format isEqualToString:@"jpg"]) {
491
493
  data = UIImageJPEGRepresentation(compositeImage, quality);
492
494
  }
493
-
495
+
494
496
  if ([result isEqualToString:@"file"]) {
495
497
  [data writeToFile:filePath atomically:YES];
496
498
  success(filePath);
@@ -558,7 +560,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
558
560
  if (!CLLocationCoordinate2DIsValid(region.center)) {
559
561
  return;
560
562
  }
561
-
563
+
562
564
  // If new span values are nil, use old values instead
563
565
  if (!region.span.latitudeDelta) {
564
566
  region.span.latitudeDelta = self.region.span.latitudeDelta;
@@ -566,7 +568,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
566
568
  if (!region.span.longitudeDelta) {
567
569
  region.span.longitudeDelta = self.region.span.longitudeDelta;
568
570
  }
569
-
571
+
570
572
  // Animate/move to new position
571
573
  [super setRegion:region animated:animated];
572
574
  }
@@ -637,25 +639,25 @@ const NSInteger AIRMapMaxZoomLevel = 20;
637
639
 
638
640
  - (void)setCameraZoomRange:(NSDictionary *)cameraZoomRange {
639
641
  if (@available(iOS 13.0, *)) {
640
-
642
+
641
643
  if (cameraZoomRange == nil) {
642
644
  cameraZoomRange = @{};
643
645
  }
644
-
646
+
645
647
  NSNumber *minValue = cameraZoomRange[@"minCenterCoordinateDistance"];
646
648
  NSNumber *maxValue = cameraZoomRange[@"maxCenterCoordinateDistance"];
647
-
649
+
648
650
  if (minValue == nil && maxValue == nil) {
649
651
  self.legacyZoomConstraintsEnabled = YES;
650
-
652
+
651
653
  MKMapCameraZoomRange *defaultZoomRange = [[MKMapCameraZoomRange alloc] initWithMinCenterCoordinateDistance:MKMapCameraZoomDefault maxCenterCoordinateDistance:MKMapCameraZoomDefault];
652
654
  [super setCameraZoomRange:defaultZoomRange animated:NO];
653
-
655
+
654
656
  return;
655
657
  }
656
-
658
+
657
659
  MKMapCameraZoomRange *zoomRange = nil;
658
-
660
+
659
661
  if (minValue != nil && maxValue != nil) {
660
662
  zoomRange = [[MKMapCameraZoomRange alloc] initWithMinCenterCoordinateDistance:[minValue doubleValue] maxCenterCoordinateDistance:[maxValue doubleValue]];
661
663
  } else if (minValue != nil) {
@@ -663,9 +665,9 @@ const NSInteger AIRMapMaxZoomLevel = 20;
663
665
  } else if (maxValue != nil) {
664
666
  zoomRange = [[MKMapCameraZoomRange alloc] initWithMaxCenterCoordinateDistance:[maxValue doubleValue]];
665
667
  }
666
-
668
+
667
669
  BOOL animated = [cameraZoomRange[@"animated"] boolValue];
668
-
670
+
669
671
  self.legacyZoomConstraintsEnabled = NO;
670
672
  [super setCameraZoomRange:zoomRange animated:animated];
671
673
  }
@@ -716,7 +718,7 @@ const NSInteger AIRMapMaxZoomLevel = 20;
716
718
  else {
717
719
  self.cacheImageView.image = nil;
718
720
  self.cacheImageView.hidden = YES;
719
-
721
+
720
722
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
721
723
  self.cacheImageView.image = nil;
722
724
  self.cacheImageView.hidden = YES;
@@ -724,12 +726,12 @@ const NSInteger AIRMapMaxZoomLevel = 20;
724
726
  [self.layer renderInContext:UIGraphicsGetCurrentContext()];
725
727
  UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
726
728
  UIGraphicsEndImageContext();
727
-
729
+
728
730
  self.cacheImageView.image = image;
729
731
  self.cacheImageView.hidden = NO;
730
732
  });
731
733
  }
732
-
734
+
733
735
  [self updateScrollEnabled];
734
736
  [self updateZoomEnabled];
735
737
  [self updateLegalLabelInsets];
@@ -859,22 +861,22 @@ const NSInteger AIRMapMaxZoomLevel = 20;
859
861
  // based on https://medium.com/@dmytrobabych/getting-actual-rotation-and-zoom-level-for-mapkit-mkmapview-e7f03f430aa9
860
862
  - (CGFloat)getZoomLevel {
861
863
  CGFloat cameraAngle = self.camera.heading;
862
-
864
+
863
865
  if (cameraAngle > 270) {
864
866
  cameraAngle = 360 - cameraAngle;
865
867
  } else if (cameraAngle > 90) {
866
868
  cameraAngle = fabs(cameraAngle - 180);
867
869
  }
868
-
870
+
869
871
  CGFloat angleRad = M_PI * cameraAngle / 180; // map rotation in radians
870
872
  CGFloat width = self.frame.size.width;
871
873
  CGFloat height = self.frame.size.height;
872
874
  CGFloat heightOffset = 20; // the offset (status bar height) which is taken by MapKit into consideration to calculate visible area height
873
-
875
+
874
876
  // calculating Longitude span corresponding to normal (non-rotated) width
875
877
  CGFloat spanStraight = width * self.region.span.longitudeDelta / (width * cos(angleRad) + (height - heightOffset) * sin(angleRad));
876
878
  int normalizingFactor = 512;
877
-
879
+
878
880
  return log2(360 * ((width / normalizingFactor) / spanStraight));
879
881
  }
880
882
 
@@ -115,7 +115,8 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
115
115
 
116
116
  _pinView.draggable = self.draggable;
117
117
  _pinView.layer.zPosition = self.zIndex;
118
-
118
+ _pinView.displayPriority = self.displayPriority;
119
+ _pinView.zPriority = self.zIndex;
119
120
  return _pinView;
120
121
  }
121
122
 
@@ -131,6 +132,9 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
131
132
  _markerView.markerTintColor = self.pinColor;
132
133
  _markerView.titleVisibility = self.titleVisibility ?: MKFeatureVisibilityHidden;
133
134
  _markerView.subtitleVisibility = self.subtitleVisibility ?: MKFeatureVisibilityHidden;
135
+ _markerView.displayPriority = self.displayPriority;
136
+ _markerView.zPriority = self.zIndex;
137
+
134
138
 
135
139
  }
136
140
  return _markerView ?: _pinView;
@@ -140,6 +144,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
140
144
  // In either case, we want to return the AIRMapMarker since it is both an MKAnnotation and an
141
145
  // MKAnnotationView all at the same time.
142
146
  self.layer.zPosition = self.zIndex;
147
+ self.zPriority = self.zIndex;
143
148
  return self;
144
149
  }
145
150
  }
@@ -496,6 +496,7 @@ newViewProps.name.right); \
496
496
  REMAP_MAPVIEW_PROP(userLocationCalloutEnabled)
497
497
  REMAP_MAPVIEW_PROP(zoomEnabled)
498
498
 
499
+
499
500
  REMAP_MAPVIEW_POINT_PROP(compassOffset)
500
501
 
501
502
  if (![_view ignoreRegionChanges]){
@@ -390,6 +390,21 @@ _view.name = CGPointMake(newViewProps.name.x, newViewProps.name.y); \
390
390
 
391
391
  }
392
392
  }
393
+
394
+ if (newViewProps.displayPriority != oldViewProps.displayPriority){
395
+ switch (newViewProps.displayPriority) {
396
+ case RNMapsMarkerDisplayPriority::Required:
397
+ [_view setDisplayPriority:MKFeatureDisplayPriorityRequired];
398
+ break;
399
+ case RNMapsMarkerDisplayPriority::High:
400
+ [_view setDisplayPriority:MKFeatureDisplayPriorityDefaultHigh];
401
+ break;
402
+ case RNMapsMarkerDisplayPriority::Low:
403
+ [_view setDisplayPriority:MKFeatureDisplayPriorityDefaultLow];
404
+ break;
405
+
406
+ }
407
+ }
393
408
 
394
409
 
395
410
  [super updateProps:props oldProps:oldProps];
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import { Animated, ViewProps, ImageURISource, ImageRequireSource } from 'react-native';
3
3
  import { MapManagerCommand, NativeComponent, ProviderContext, UIManagerCommand } from './decorateMapComponent';
4
4
  import { MapMarkerNativeComponentType } from './MapMarkerNativeComponent';
5
+ import type { AppleMarkerPriority } from './specs/NativeComponentMarker';
5
6
  import { CalloutPressEvent, LatLng, MarkerDeselectEvent, MarkerDragEvent, MarkerDragStartEndEvent, MarkerPressEvent, MarkerSelectEvent, Point } from './sharedTypes';
6
7
  import { Modify } from './sharedTypesInternal';
7
8
  type AppleMarkerVisibility = 'hidden' | 'adaptive' | 'visible';
@@ -261,6 +262,17 @@ export type MapMarkerProps = ViewProps & {
261
262
  * @platform Android: Supported
262
263
  */
263
264
  zIndex?: number;
265
+ /**
266
+ Constants that indicates the display priority for annotations.
267
+ @default required
268
+ @platform iOS: Apple Maps only.
269
+ @platform Android: Not supported
270
+
271
+ Required: A constant indicating that the item is required.
272
+ High: A constant indicating that the item’s display priority is high.
273
+ Low: A constant indicating that the item’s display priority is Low.
274
+ */
275
+ displayPriority?: AppleMarkerPriority;
264
276
  /**
265
277
  * Visibility of the title text rendered beneath Marker balloon
266
278
  * @platform iOS: Apple Maps only
@@ -40,6 +40,7 @@ export type CalloutPressEventHandler = BubblingEventHandler<Readonly<{
40
40
  };
41
41
  }>>;
42
42
  type AppleMarkerVisibility = 'hidden' | 'adaptive' | 'visible';
43
+ export type AppleMarkerPriority = 'required' | 'high' | 'low';
43
44
  export type Point = Readonly<{
44
45
  x: Double;
45
46
  y: Double;
@@ -91,6 +92,17 @@ export interface MarkerFabricNativeProps extends ViewProps {
91
92
  * @platform Android: Not supported. See the `calloutAnchor` prop
92
93
  */
93
94
  calloutOffset?: Point;
95
+ /**
96
+ Constants that indicates the display priority for annotations.
97
+ @default required
98
+ @platform iOS: Apple Maps only.
99
+ @platform Android: Not supported
100
+
101
+ Required: A constant indicating that the item is required.
102
+ High: A constant indicating that the item’s display priority is high.
103
+ Low: A constant indicating that the item’s display priority is Low.
104
+ */
105
+ displayPriority?: WithDefault<AppleMarkerPriority, 'required'>;
94
106
  /**
95
107
  * The coordinate for the marker.
96
108
  *
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "main": "lib/index.js",
6
6
  "author": "Leland Richardson <leland.m.richardson@gmail.com>",
7
7
  "homepage": "https://github.com/react-native-maps/react-native-maps#readme",
8
- "version": "1.21.0-alpha.32",
8
+ "version": "1.21.0-alpha.33",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",