react-native-maps 1.21.0-alpha.19 → 1.21.0-alpha.20

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.
@@ -14,6 +14,8 @@
14
14
  #import <React/RCTImageLoaderProtocol.h>
15
15
  #import <React/RCTUtils.h>
16
16
  #import <React/UIView+React.h>
17
+ #import <React/RCTImageLoader.h>
18
+ #import <React/RCTBridge+Private.h>
17
19
 
18
20
  NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
19
21
 
@@ -68,6 +70,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
68
70
  self.calloutView = (AIRMapCallout *)subview;
69
71
  } else {
70
72
  [super insertReactSubview:(UIView *)subview atIndex:atIndex];
73
+ [self addSubview:subview];
71
74
  }
72
75
  }
73
76
  - (void) setFrame:(CGRect)frame {
@@ -84,6 +87,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
84
87
  self.calloutView = nil;
85
88
  } else {
86
89
  [super removeReactSubview:(UIView *)subview];
90
+ [(UIView *) subview removeFromSuperview];
87
91
  }
88
92
  }
89
93
 
@@ -344,7 +348,8 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
344
348
  _reloadImageCancellationBlock();
345
349
  _reloadImageCancellationBlock = nil;
346
350
  }
347
- _reloadImageCancellationBlock = [[_bridge moduleForName:@"ImageLoader"] loadImageWithURLRequest:[RCTConvert NSURLRequest:_imageSrc]
351
+
352
+ _reloadImageCancellationBlock = [[[RCTBridge currentBridge] moduleForName:@"ImageLoader"] loadImageWithURLRequest:[RCTConvert NSURLRequest:_imageSrc]
348
353
  size:self.bounds.size
349
354
  scale:RCTScreenScale()
350
355
  clipped:YES
@@ -352,9 +357,10 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
352
357
  progressBlock:nil
353
358
  partialLoadBlock:nil
354
359
  completionBlock:^(NSError *error, UIImage *image) {
360
+ NSLog(@"image load completed");
355
361
  if (error) {
356
362
  // TODO(lmr): do something with the error?
357
- NSLog(@"%@", error);
363
+ NSLog(@"failed to load image: %@", error);
358
364
  }
359
365
  dispatch_async(dispatch_get_main_queue(), ^{
360
366
  self.image = image;
@@ -10,6 +10,7 @@
10
10
  #import "AirMap.h"
11
11
  #import "AIRMapMarker.h"
12
12
  #import "AIRMapManager.h"
13
+ #import "RNMapsMarkerView.h"
13
14
  #import <react/renderer/components/RNMapsSpecs/ComponentDescriptors.h>
14
15
  #import <react/renderer/components/RNMapsSpecs/EventEmitters.h>
15
16
  #import <react/renderer/components/RNMapsSpecs/Props.h>
@@ -371,16 +372,25 @@ mapViewEventEmitter->emitterFunction(data); \
371
372
  id<RCTComponent> paperView = [childComponentView getPaperViewFromChildComponentView];
372
373
  if (paperView){
373
374
  [_view insertReactSubview:paperView atIndex:index];
374
- } else {
375
+ } else if ([childComponentView isKindOfClass:[RNMapsMarkerView class]]){
376
+ RNMapsMarkerView* fabricMarker = (RNMapsMarkerView *) childComponentView;
377
+ [_view insertReactSubview:[fabricMarker marker] atIndex:index];
378
+ }
379
+ else {
375
380
  [_view insertReactSubview:childComponentView atIndex:index];
376
381
  }
377
382
  }
383
+
378
384
  - (void) unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
379
385
  {
380
386
  id<RCTComponent> paperView = [childComponentView getPaperViewFromChildComponentView];
381
387
  if (paperView){
382
388
  [_view removeReactSubview:paperView];
383
- } else {
389
+ }
390
+ else if ([childComponentView isKindOfClass:[RNMapsMarkerView class]]){
391
+ RNMapsMarkerView* fabricMarker = (RNMapsMarkerView *) childComponentView;
392
+ [_view removeReactSubview:[fabricMarker marker]];
393
+ } else {
384
394
  [_view removeReactSubview:childComponentView];
385
395
  }
386
396
  }
@@ -42,7 +42,7 @@ export type MapMarkerProps = ViewProps & {
42
42
  *
43
43
  * @default {x: 0.0, y: 0.0}
44
44
  * @platform iOS: Apple Maps only. For Google Maps, see the `calloutAnchor` prop
45
- * @platform Android: Not supported. See see the `calloutAnchor` prop
45
+ * @platform Android: Not supported. see the `calloutAnchor` prop
46
46
  */
47
47
  calloutOffset?: Point;
48
48
  /**
@@ -54,7 +54,7 @@ export type MapMarkerProps = ViewProps & {
54
54
  *
55
55
  * @default {x: 0.0, y: 0.0}
56
56
  * @platform iOS: Apple Maps only. For Google Maps, see the `anchor` prop
57
- * @platform Android: Not supported. See see the `anchor` prop
57
+ * @platform Android: Not supported. see the `anchor` prop
58
58
  */
59
59
  centerOffset?: Point;
60
60
  /**
package/lib/MapMarker.js CHANGED
@@ -28,6 +28,7 @@ const React = __importStar(require("react"));
28
28
  const react_native_1 = require("react-native");
29
29
  const decorateMapComponent_1 = __importStar(require("./decorateMapComponent"));
30
30
  const MapMarkerNativeComponent_1 = require("./MapMarkerNativeComponent");
31
+ const ProviderConstants_1 = require("./ProviderConstants");
31
32
  class MapMarker extends React.Component {
32
33
  getNativeComponent;
33
34
  getMapManagerCommand;
@@ -79,17 +80,23 @@ class MapMarker extends React.Component {
79
80
  }
80
81
  render() {
81
82
  const { stopPropagation = false } = this.props;
82
- let image;
83
- if (this.props.image) {
84
- image = react_native_1.Image.resolveAssetSource(this.props.image) || {};
85
- image = image.uri || this.props.image;
86
- }
87
83
  let icon;
88
84
  if (this.props.icon) {
89
85
  icon = react_native_1.Image.resolveAssetSource(this.props.icon) || {};
90
86
  icon = icon.uri;
91
87
  }
92
88
  const AIRMapMarker = this.getNativeComponent();
89
+ const provider = this.context;
90
+ let image;
91
+ if (this.props.image) {
92
+ if (provider !== ProviderConstants_1.PROVIDER_GOOGLE && react_native_1.Platform.OS === 'ios') {
93
+ image = this.props.image;
94
+ }
95
+ else {
96
+ image = react_native_1.Image.resolveAssetSource(this.props.image) || {};
97
+ image = image.uri || this.props.image;
98
+ }
99
+ }
93
100
  return (<AIRMapMarker {...this.props} ref={this.marker} image={image} icon={icon} style={[styles.marker, this.props.style]} onPress={event => {
94
101
  if (stopPropagation) {
95
102
  event.stopPropagation();
@@ -9,9 +9,7 @@ exports.Commands = (0, codegenNativeCommands_1.default)({
9
9
  supportedCommands: [
10
10
  'showCallout',
11
11
  'hideCallout',
12
- 'redrawCallout',
13
12
  'animateMarkerToCoordinate',
14
- 'redraw',
15
13
  'setCoordinates',
16
14
  ],
17
15
  });
@@ -8,6 +8,7 @@ const react_1 = require("react");
8
8
  const react_native_1 = require("react-native");
9
9
  const ProviderConstants_1 = require("./ProviderConstants");
10
10
  const NativeComponentGooglePolygon_1 = __importDefault(require("./specs/NativeComponentGooglePolygon"));
11
+ const NativeComponentMarker_1 = __importDefault(require("./specs/NativeComponentMarker"));
11
12
  exports.SUPPORTED = 'SUPPORTED';
12
13
  exports.USES_DEFAULT_IMPLEMENTATION = 'USES_DEFAULT_IMPLEMENTATION';
13
14
  exports.NOT_SUPPORTED = 'NOT_SUPPORTED';
@@ -38,6 +39,12 @@ function decorateMapComponent(Component, componentName, providers) {
38
39
  Component.prototype.getNativeComponent =
39
40
  function getNativeComponent() {
40
41
  const provider = this.context;
42
+ if (componentName === 'Marker' &&
43
+ provider !== ProviderConstants_1.PROVIDER_GOOGLE &&
44
+ react_native_1.Platform.OS === 'ios') {
45
+ // @ts-ignore
46
+ return NativeComponentMarker_1.default;
47
+ }
41
48
  const key = provider || 'default';
42
49
  if (components[key]) {
43
50
  return components[key];
@@ -0,0 +1,245 @@
1
+ /// <reference types="react" />
2
+ import { HostComponent } from 'react-native';
3
+ import type { ViewProps, ColorValue, ImageSourcePropType as ImageSource } from 'react-native';
4
+ import { Int32, Double, BubblingEventHandler, DirectEventHandler, WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
5
+ export type LatLng = Readonly<{
6
+ latitude: Double;
7
+ longitude: Double;
8
+ }>;
9
+ export type MarkerPressEventHandler = BubblingEventHandler<Readonly<{
10
+ action: string;
11
+ id?: string;
12
+ coordinate?: {
13
+ latitude: Double;
14
+ longitude: Double;
15
+ };
16
+ position?: {
17
+ x: Double;
18
+ y: Double;
19
+ };
20
+ }>>;
21
+ export type MarkerDragEventHandler = DirectEventHandler<Readonly<{
22
+ id?: string;
23
+ coordinate?: {
24
+ latitude: Double;
25
+ longitude: Double;
26
+ };
27
+ }>>;
28
+ export type CalloutPressEventHandler = BubblingEventHandler<Readonly<{
29
+ action: string;
30
+ id?: string;
31
+ frame?: {
32
+ x: Double;
33
+ y: Double;
34
+ width: Double;
35
+ height: Double;
36
+ };
37
+ point?: {
38
+ x: Double;
39
+ y: Double;
40
+ };
41
+ }>>;
42
+ type AppleMarkerVisibility = 'hidden' | 'adaptive' | 'visible';
43
+ export type Point = Readonly<{
44
+ x: Double;
45
+ y: Double;
46
+ }>;
47
+ export interface MarkerFabricNativeProps extends ViewProps {
48
+ /**
49
+ * Sets the anchor point for the marker.
50
+ * The anchor specifies the point in the icon image that is anchored to the marker's position on the Earth's surface.
51
+ *
52
+ * The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0],
53
+ * where (0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner.
54
+ *
55
+ * The anchoring point in a W x H image is the nearest discrete grid point in a (W + 1) x (H + 1) grid, obtained by scaling the then rounding.
56
+ * For example, in a 4 x 2 image, the anchor point (0.7, 0.6) resolves to the grid point at (3, 1).
57
+ *
58
+ * @default {x: 0.5, y: 1.0}
59
+ * @platform iOS: Google Maps only. For Apple Maps, see the `centerOffset` prop
60
+ * @platform Android: Supported
61
+ */
62
+ anchor?: Point;
63
+ /**
64
+ * Specifies the point in the marker image at which to anchor the callout when it is displayed.
65
+ * This is specified in the same coordinate system as the anchor.
66
+ *
67
+ * See the `anchor` prop for more details.
68
+ *
69
+ * @default {x: 0.5, y: 0.0}
70
+ * @platform iOS: Google Maps only. For Apple Maps, see the `calloutOffset` prop
71
+ * @platform Android: Supported
72
+ */
73
+ calloutAnchor?: Point;
74
+ /**
75
+ * A custom image to be used as the marker's icon. Only local image resources are allowed to be used.
76
+ *
77
+ * @platform iOS: Supported
78
+ * @platform Android: Supported
79
+ */
80
+ image?: ImageSource | null;
81
+ /**
82
+ * The offset (in points) at which to place the callout bubble.
83
+ * When this property is set to (0, 0),
84
+ * the anchor point of the callout bubble is placed on the top-center point of the marker view’s frame.
85
+ *
86
+ * Specifying positive offset values moves the callout bubble down and to the right,
87
+ * while specifying negative values moves it up and to the left
88
+ *
89
+ * @default {x: 0.0, y: 0.0}
90
+ * @platform iOS: Apple Maps only. For Google Maps, see the `calloutAnchor` prop
91
+ * @platform Android: Not supported. See the `calloutAnchor` prop
92
+ */
93
+ calloutOffset?: Point;
94
+ /**
95
+ * The coordinate for the marker.
96
+ *
97
+ * @platform iOS: Supported
98
+ * @platform Android: Supported
99
+ */
100
+ coordinate: LatLng;
101
+ /**
102
+ * The description of the marker.
103
+ *
104
+ * This is only used if the <Marker /> component has no children that are a `<Callout />`,
105
+ * in which case the default callout behavior will be used,
106
+ * which will show both the `title` and the `description`, if provided.
107
+ *
108
+ * @platform iOS: Supported
109
+ * @platform Android: Supported
110
+ */
111
+ description?: string;
112
+ /**
113
+ * if `true` allows the marker to be draggable (re-positioned).
114
+ *
115
+ * @default false
116
+ * @platform iOS: Supported
117
+ * @platform Android: Supported
118
+ */
119
+ draggable?: boolean;
120
+ /**
121
+ * The title of the marker.
122
+ * This is only used if the <Marker /> component has no `<Callout />` children.
123
+ *
124
+ * If the marker has <Callout /> children, default callout behavior will be used,
125
+ * which will show both the `title` and the `description`, if provided.
126
+ *
127
+ * @platform iOS: Supported
128
+ * @platform Android: Supported
129
+ */
130
+ title?: string;
131
+ /**
132
+ * A string that can be used to identify this marker.
133
+ *
134
+ * @platform iOS: Supported
135
+ * @platform Android: Supported
136
+ */
137
+ identifier?: string;
138
+ /**
139
+ * When true, the marker will be pre-selected.
140
+ * Setting this to true allows the user to drag the marker without needing to tap on it first to focus it.
141
+ *
142
+ * @default false
143
+ * @platform iOS: Apple Maps only
144
+ * @platform Android: Not supported
145
+ */
146
+ isPreselected?: boolean;
147
+ /**
148
+ * Callback that is called when the user taps the callout view.
149
+ *
150
+ * @platform iOS: Apple Maps only
151
+ * @platform Android: Supported
152
+ */
153
+ onCalloutPress?: CalloutPressEventHandler;
154
+ /**
155
+ * Callback that is called when the marker is deselected, before the callout is hidden.
156
+ *
157
+ * @platform iOS: Apple Maps only
158
+ * @platform Android: Not supported
159
+ */
160
+ onDeselect?: MarkerPressEventHandler;
161
+ /**
162
+ * Callback called continuously as the marker is dragged
163
+ *
164
+ * @platform iOS: Apple Maps only
165
+ * @platform Android: Supported
166
+ */
167
+ onDrag?: MarkerDragEventHandler;
168
+ /**
169
+ * Callback that is called when a drag on the marker finishes.
170
+ * This is usually the point you will want to setState on the marker's coordinate again
171
+ *
172
+ * @platform iOS: Apple Maps only
173
+ * @platform Android: Supported
174
+ */
175
+ onDragEnd?: MarkerDragEventHandler;
176
+ /**
177
+ * Callback that is called when the user initiates a drag on the marker (if it is draggable)
178
+ *
179
+ * @platform iOS: Apple Maps only
180
+ * @platform Android: Supported
181
+ */
182
+ onDragStart?: MarkerDragEventHandler;
183
+ /**
184
+ * Callback that is called when the marker is tapped by the user.
185
+ *
186
+ * @platform iOS: Supported
187
+ * @platform Android: Supported
188
+ */
189
+ onPress?: MarkerPressEventHandler;
190
+ /**
191
+ * Callback that is called when the marker becomes selected.
192
+ * This will be called when the callout for that marker is about to be shown.
193
+ *
194
+ * @platform iOS: Supported.
195
+ * @platform Android: Supported
196
+ */
197
+ onSelect?: MarkerPressEventHandler;
198
+ /**
199
+ * The marker's opacity between 0.0 and 1.0.
200
+ *
201
+ * @default 1.0
202
+ * @platform iOS: Supported
203
+ * @platform Android: Supported
204
+ */
205
+ opacity?: WithDefault<Double, 1.0>;
206
+ /**
207
+ * If no custom marker view or custom image is provided, the platform default pin will be used, which can be customized by this color.
208
+ * Ignored if a custom marker is being used.<br/><br/>
209
+ * For Android, the set of available colors is limited. Unsupported colors will fall back to red.
210
+ * See [#887](https://github.com/react-community/react-native-maps/issues/887) for more information.
211
+ *
212
+ * @platform iOS: Supported
213
+ * @platform Android: Supported
214
+ */
215
+ pinColor?: ColorValue;
216
+ /**
217
+ * Visibility of the title text rendered beneath Marker balloon
218
+ * @platform iOS: Apple Maps only
219
+ * @platform Android: Not supported
220
+ */
221
+ titleVisibility?: WithDefault<AppleMarkerVisibility, 'visible'>;
222
+ /**
223
+ * Visibility of the subtitle text rendered beneath Marker balloon
224
+ * @platform iOS: Apple Maps only
225
+ * @platform Android: Not supported
226
+ */
227
+ subtitleVisibility?: WithDefault<AppleMarkerVisibility, 'adaptive'>;
228
+ /**
229
+ * Indicate type of default markers if it's true MKPinAnnotationView will be used and MKMarkerAnnotationView if it's false
230
+ * It doesn't change anything if you are using custom Markers
231
+ * @platform iOS: Apple Maps only
232
+ * @platform Android: Not supported
233
+ */
234
+ useLegacyPinView?: boolean;
235
+ }
236
+ export interface NativeCommands {
237
+ animateToCoordinates: (viewRef: React.ElementRef<React.ComponentType>, latitude: Double, longitude: Double, duration: Int32) => void;
238
+ showCallout: (viewRef: React.ElementRef<React.ComponentType>) => void;
239
+ hideCallout: (viewRef: React.ElementRef<React.ComponentType>) => void;
240
+ redrawCallout: (viewRef: React.ElementRef<React.ComponentType>) => void;
241
+ redraw: (viewRef: React.ElementRef<React.ComponentType>) => void;
242
+ }
243
+ export declare const Commands: NativeCommands;
244
+ declare const _default: HostComponent<MarkerFabricNativeProps>;
245
+ export default _default;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Commands = void 0;
7
+ const codegenNativeComponent_1 = __importDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));
8
+ const codegenNativeCommands_1 = __importDefault(require("react-native/Libraries/Utilities/codegenNativeCommands"));
9
+ exports.Commands = (0, codegenNativeCommands_1.default)({
10
+ supportedCommands: [
11
+ 'animateToCoordinates',
12
+ 'showCallout',
13
+ 'hideCallout',
14
+ 'redrawCallout',
15
+ 'redraw',
16
+ ],
17
+ });
18
+ exports.default = (0, codegenNativeComponent_1.default)('RNMapsMarker', {
19
+ excludedPlatforms: ['android'],
20
+ });
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.19",
8
+ "version": "1.21.0-alpha.20",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",