react-native-maps 1.14.0 → 1.15.0

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.
@@ -35,6 +35,9 @@
35
35
  @property (nonatomic, assign) NSInteger zIndex;
36
36
  @property (nonatomic, assign) double opacity;
37
37
  @property (nonatomic, assign) BOOL isPreselected;
38
+ @property (nonatomic, assign) MKFeatureVisibility titleVisibility;
39
+ @property (nonatomic, assign) MKFeatureVisibility subtitleVisibility;
40
+ @property (nonatomic, assign) BOOL useLegacyPinView;
38
41
 
39
42
  @property (nonatomic, copy) RCTBubblingEventBlock onPress;
40
43
  @property (nonatomic, copy) RCTDirectEventBlock onSelect;
@@ -51,6 +54,7 @@
51
54
  - (void)showCalloutView;
52
55
  - (void)hideCalloutView;
53
56
  - (void)addTapGestureRecognizer;
57
+ - (void)setUseLegacyPinView:(BOOL)value;
54
58
 
55
59
  @end
56
60
 
@@ -23,9 +23,11 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
23
23
  @implementation AIRMapMarker {
24
24
  BOOL _hasSetCalloutOffset;
25
25
  RCTImageLoaderCancellationBlock _reloadImageCancellationBlock;
26
+ MKMarkerAnnotationView *_markerView;
26
27
  MKPinAnnotationView *_pinView;
27
28
  BOOL _calloutIsOpen;
28
29
  NSInteger _zIndexBeforeOpen;
30
+ BOOL _useLegacyPinView;
29
31
  }
30
32
 
31
33
  - (instancetype)initWithFrame:(CGRect)frame {
@@ -80,24 +82,39 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
80
82
  - (MKAnnotationView *)getAnnotationView
81
83
  {
82
84
  if ([self shouldUsePinView]) {
83
- // In this case, we want to render a platform "default" marker.
84
- if (_pinView == nil) {
85
+ // In this case, we want to render a platform "default" legacy marker.
86
+
87
+
88
+ if (_pinView == nil && _useLegacyPinView) {
85
89
  _pinView = [[MKPinAnnotationView alloc] initWithAnnotation:self reuseIdentifier: nil];
86
90
  [self addGestureRecognizerToView:_pinView];
87
91
  _pinView.annotation = self;
88
- }
89
92
 
90
- _pinView.draggable = self.draggable;
91
- _pinView.layer.zPosition = self.zIndex;
93
+ if ([_pinView respondsToSelector:@selector(setPinTintColor:)]) {
94
+ _pinView.pinTintColor = self.pinColor;
95
+ }
92
96
 
93
- // TODO(lmr): Looks like this API was introduces in iOS 8. We may want to handle differently for earlier
94
- // versions. Right now it's just leaving it with the default color. People needing the colors are free to
95
- // use their own custom markers.
96
- if ([_pinView respondsToSelector:@selector(setPinTintColor:)]) {
97
- _pinView.pinTintColor = self.pinColor;
97
+ _pinView.draggable = self.draggable;
98
+ _pinView.layer.zPosition = self.zIndex;
99
+
100
+ return _pinView;
98
101
  }
102
+
103
+
104
+
105
+ if (_markerView == nil && !_useLegacyPinView) {
106
+ _markerView = [[MKMarkerAnnotationView alloc] initWithAnnotation:self reuseIdentifier: nil];
107
+ [self addGestureRecognizerToView:_markerView];
108
+ _markerView.annotation = self;
99
109
 
100
- return _pinView;
110
+ _markerView.draggable = self.draggable;
111
+ _markerView.layer.zPosition = self.zIndex;
112
+ _markerView.markerTintColor = self.pinColor;
113
+ _markerView.titleVisibility = self.titleVisibility ?: MKFeatureVisibilityHidden;
114
+ _markerView.subtitleVisibility = self.subtitleVisibility ?: MKFeatureVisibilityHidden;
115
+
116
+ }
117
+ return _markerView ?: _pinView;
101
118
  } else {
102
119
  // If it has subviews, it means we are wanting to render a custom marker with arbitrary react views.
103
120
  // if it has a non-null image, it means we want to render a custom marker with the image.
@@ -113,7 +130,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
113
130
  // Set everything necessary on the calloutView before it becomes visible.
114
131
 
115
132
  // Apply the MKAnnotationView's desired calloutOffset (from the top-middle of the view)
116
- if ([self shouldUsePinView] && !_hasSetCalloutOffset) {
133
+ if ([self shouldUsePinView] && !_hasSetCalloutOffset && _useLegacyPinView) {
117
134
  calloutView.calloutOffset = CGPointMake(-8,0);
118
135
  } else {
119
136
  calloutView.calloutOffset = self.calloutOffset;
@@ -336,8 +353,10 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
336
353
  {
337
354
  _pinColor = pinColor;
338
355
 
339
- if ([_pinView respondsToSelector:@selector(setPinTintColor:)]) {
356
+ if(_useLegacyPinView && [_pinView respondsToSelector:@selector(setPinTintColor:)]) {
340
357
  _pinView.pinTintColor = _pinColor;
358
+ } else {
359
+ _markerView.markerTintColor = _pinColor;
341
360
  }
342
361
  }
343
362
 
@@ -362,4 +381,8 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
362
381
  }
363
382
  }
364
383
 
384
+ - (void)setUseLegacyPinView:(BOOL)value {
385
+ _useLegacyPinView = value;
386
+ }
387
+
365
388
  @end
@@ -46,6 +46,9 @@ RCT_EXPORT_VIEW_PROPERTY(draggable, BOOL)
46
46
  RCT_EXPORT_VIEW_PROPERTY(zIndex, NSInteger)
47
47
  RCT_EXPORT_VIEW_PROPERTY(opacity, double)
48
48
  RCT_EXPORT_VIEW_PROPERTY(isPreselected, BOOL)
49
+ RCT_EXPORT_VIEW_PROPERTY(titleVisibility, NSString)
50
+ RCT_EXPORT_VIEW_PROPERTY(subtitleVisibility, NSString)
51
+ RCT_EXPORT_VIEW_PROPERTY(useLegacyPinView, BOOL)
49
52
 
50
53
  RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
51
54
  RCT_EXPORT_VIEW_PROPERTY(onSelect, RCTDirectEventBlock)
@@ -4,6 +4,7 @@ import { MapManagerCommand, NativeComponent, ProviderContext, UIManagerCommand }
4
4
  import { MapMarkerNativeComponentType } from './MapMarkerNativeComponent';
5
5
  import { CalloutPressEvent, LatLng, MarkerDeselectEvent, MarkerDragEvent, MarkerDragStartEndEvent, MarkerPressEvent, MarkerSelectEvent, Point } from './sharedTypes';
6
6
  import { Modify } from './sharedTypesInternal';
7
+ type AppleMarkerVisibility = 'hidden' | 'adaptive' | 'visible';
7
8
  export type MapMarkerProps = ViewProps & {
8
9
  /**
9
10
  * Sets the anchor point for the marker.
@@ -260,6 +261,25 @@ export type MapMarkerProps = ViewProps & {
260
261
  * @platform Android: Supported
261
262
  */
262
263
  zIndex?: number;
264
+ /**
265
+ * Visibility of the title text rendered beneath Marker balloon
266
+ * @platform iOS: Apple Maps only
267
+ * @platform Android: Not supported
268
+ */
269
+ titleVisibility?: AppleMarkerVisibility;
270
+ /**
271
+ * Visibility of the subtitle text rendered beneath Marker balloon
272
+ * @platform iOS: Apple Maps only
273
+ * @platform Android: Not supported
274
+ */
275
+ subtitleVisibility?: AppleMarkerVisibility;
276
+ /**
277
+ * Indicate type of default markers if it's true MKPinAnnotationView will be used and MKMarkerAnnotationView if it's false
278
+ * It doesn't change anything if you are using custom Markers
279
+ * @platform iOS: Apple Maps only
280
+ * @platform Android: Not supported
281
+ */
282
+ useLegacyPinView?: boolean;
263
283
  };
264
284
  type OmittedProps = Omit<MapMarkerProps, 'stopPropagation'>;
265
285
  export type NativeProps = Modify<OmittedProps, {
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.14.0",
8
+ "version": "1.15.0",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",