react-native-maps 1.3.0-beta.1 → 1.3.0-beta.2

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,9 +14,9 @@
14
14
  @property (nonatomic, strong) GMSCircle *circle;
15
15
  @property (nonatomic, assign) double radius;
16
16
  @property (nonatomic, assign) CLLocationCoordinate2D centerCoordinate;
17
- @property (nonatomic, assign) UIColor *strokeColor;
17
+ @property (nonatomic, strong) UIColor *strokeColor;
18
18
  @property (nonatomic, assign) double strokeWidth;
19
- @property (nonatomic, assign) UIColor *fillColor;
19
+ @property (nonatomic, strong) UIColor *fillColor;
20
20
  @property (nonatomic, assign) int zIndex;
21
21
 
22
22
  @end
@@ -11,15 +11,34 @@
11
11
  #import <React/RCTUtils.h>
12
12
 
13
13
  @implementation AIRGoogleMapCircle
14
+ {
15
+ BOOL _didMoveToWindow;
16
+ }
14
17
 
15
18
  - (instancetype)init
16
19
  {
17
20
  if (self = [super init]) {
21
+ _didMoveToWindow = false;
18
22
  _circle = [[GMSCircle alloc] init];
19
23
  }
20
24
  return self;
21
25
  }
22
26
 
27
+ - (void)didMoveToWindow {
28
+ [super didMoveToWindow];
29
+ if(_didMoveToWindow) return;
30
+ _didMoveToWindow = true;
31
+ if(_fillColor) {
32
+ _circle.fillColor = _fillColor;
33
+ }
34
+ if(_strokeColor) {
35
+ _circle.strokeColor = _strokeColor;
36
+ }
37
+ if(_strokeWidth) {
38
+ _circle.strokeWidth = _strokeWidth;
39
+ }
40
+ }
41
+
23
42
  - (void)setRadius:(double)radius
24
43
  {
25
44
  _radius = radius;
@@ -35,19 +54,25 @@
35
54
  -(void)setStrokeColor:(UIColor *)strokeColor
36
55
  {
37
56
  _strokeColor = strokeColor;
38
- _circle.strokeColor = strokeColor;
57
+ if(_didMoveToWindow) {
58
+ _circle.strokeColor = strokeColor;
59
+ }
39
60
  }
40
61
 
41
62
  -(void)setStrokeWidth:(double)strokeWidth
42
63
  {
43
64
  _strokeWidth = strokeWidth;
44
- _circle.strokeWidth = strokeWidth;
65
+ if(_didMoveToWindow) {
66
+ _circle.strokeWidth = strokeWidth;
67
+ }
45
68
  }
46
69
 
47
70
  -(void)setFillColor:(UIColor *)fillColor
48
71
  {
49
72
  _fillColor = fillColor;
50
- _circle.fillColor = fillColor;
73
+ if(_didMoveToWindow) {
74
+ _circle.fillColor = fillColor;
75
+ }
51
76
  }
52
77
 
53
78
  -(void)setZIndex:(int)zIndex
@@ -20,9 +20,9 @@
20
20
  @property (nonatomic, strong) NSArray<NSArray<AIRMapCoordinate *> *> *holes;
21
21
  @property (nonatomic, copy) RCTBubblingEventBlock onPress;
22
22
 
23
- @property (nonatomic, assign) UIColor *fillColor;
23
+ @property (nonatomic, strong) UIColor *fillColor;
24
24
  @property (nonatomic, assign) double strokeWidth;
25
- @property (nonatomic, assign) UIColor *strokeColor;
25
+ @property (nonatomic, strong) UIColor *strokeColor;
26
26
  @property (nonatomic, assign) BOOL geodesic;
27
27
  @property (nonatomic, assign) int zIndex;
28
28
  @property (nonatomic, assign) BOOL tappable;
@@ -11,16 +11,35 @@
11
11
  #import <GoogleMaps/GoogleMaps.h>
12
12
 
13
13
  @implementation AIRGoogleMapPolygon
14
+ {
15
+ BOOL _didMoveToWindow;
16
+ }
14
17
 
15
18
  - (instancetype)init
16
19
  {
17
20
  if (self = [super init]) {
21
+ _didMoveToWindow = false;
18
22
  _polygon = [[AIRGMSPolygon alloc] init];
19
23
  }
20
24
 
21
25
  return self;
22
26
  }
23
27
 
28
+ - (void)didMoveToWindow {
29
+ [super didMoveToWindow];
30
+ if(_didMoveToWindow) return;
31
+ _didMoveToWindow = true;
32
+ if(_fillColor) {
33
+ _polygon.fillColor = _fillColor;
34
+ }
35
+ if(_strokeColor) {
36
+ _polygon.strokeColor = _strokeColor;
37
+ }
38
+ if(_strokeWidth) {
39
+ _polygon.strokeWidth = _strokeWidth;
40
+ }
41
+ }
42
+
24
43
  - (void)setCoordinates:(NSArray<AIRMapCoordinate *> *)coordinates
25
44
  {
26
45
  _coordinates = coordinates;
@@ -58,19 +77,25 @@
58
77
  -(void)setFillColor:(UIColor *)fillColor
59
78
  {
60
79
  _fillColor = fillColor;
61
- _polygon.fillColor = fillColor;
80
+ if(_didMoveToWindow) {
81
+ _polygon.fillColor = fillColor;
82
+ }
62
83
  }
63
84
 
64
85
  -(void)setStrokeWidth:(double)strokeWidth
65
86
  {
66
87
  _strokeWidth = strokeWidth;
67
- _polygon.strokeWidth = strokeWidth;
88
+ if(_didMoveToWindow) {
89
+ _polygon.strokeWidth = strokeWidth;
90
+ }
68
91
  }
69
92
 
70
93
  -(void)setStrokeColor:(UIColor *) strokeColor
71
94
  {
72
95
  _strokeColor = strokeColor;
73
- _polygon.strokeColor = strokeColor;
96
+ if(_didMoveToWindow) {
97
+ _polygon.strokeColor = strokeColor;
98
+ }
74
99
  }
75
100
 
76
101
  -(void)setGeodesic:(BOOL)geodesic
@@ -286,7 +286,6 @@ export declare class MapMarker extends React.Component<MapMarkerProps> {
286
286
  redrawCallout(): void;
287
287
  animateMarkerToCoordinate(coordinate: LatLng, duration?: number): void;
288
288
  redraw(): void;
289
- _getHandle(): number | null;
290
289
  render(): JSX.Element;
291
290
  }
292
291
  declare const _default: typeof MapMarker;
package/lib/MapMarker.js CHANGED
@@ -76,9 +76,6 @@ class MapMarker extends React.Component {
76
76
  MapMarkerNativeComponent_1.Commands.redraw(this.marker.current);
77
77
  }
78
78
  }
79
- _getHandle() {
80
- return (0, react_native_1.findNodeHandle)(this.marker.current);
81
- }
82
79
  render() {
83
80
  const { stopPropagation = false } = this.props;
84
81
  let image;
@@ -4,11 +4,11 @@ import { NativeProps } from './MapMarker';
4
4
  import { LatLng } from './sharedTypes';
5
5
  export declare type MapMarkerNativeComponentType = HostComponent<NativeProps>;
6
6
  interface NativeCommands {
7
- showCallout: (viewRef: React.RefObject<MapMarkerNativeComponentType>['current']) => void;
8
- hideCallout: (viewRef: React.RefObject<MapMarkerNativeComponentType>['current']) => void;
9
- redrawCallout: (viewRef: React.RefObject<MapMarkerNativeComponentType>['current']) => void;
10
- animateMarkerToCoordinate: (viewRef: React.RefObject<MapMarkerNativeComponentType>['current'], coordinate: LatLng, duration: number) => void;
11
- redraw: (viewRef: React.RefObject<MapMarkerNativeComponentType>['current']) => void;
7
+ showCallout: (viewRef: NonNullable<React.RefObject<MapMarkerNativeComponentType>['current']>) => void;
8
+ hideCallout: (viewRef: NonNullable<React.RefObject<MapMarkerNativeComponentType>['current']>) => void;
9
+ redrawCallout: (viewRef: NonNullable<React.RefObject<MapMarkerNativeComponentType>['current']>) => void;
10
+ animateMarkerToCoordinate: (viewRef: NonNullable<React.RefObject<MapMarkerNativeComponentType>['current']>, coordinate: LatLng, duration: number) => void;
11
+ redraw: (viewRef: NonNullable<React.RefObject<MapMarkerNativeComponentType>['current']>) => void;
12
12
  }
13
13
  export declare const Commands: NativeCommands;
14
14
  export {};
@@ -133,7 +133,6 @@ export declare class MapPolygon extends React.Component<MapPolygonProps> {
133
133
  private polygon;
134
134
  constructor(props: MapPolygonProps);
135
135
  setNativeProps(props: Partial<MapPolygonProps>): void;
136
- updateNativeProps(): () => void;
137
136
  render(): JSX.Element;
138
137
  }
139
138
  declare const _default: typeof MapPolygon;
package/lib/MapPolygon.js CHANGED
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.MapPolygon = void 0;
27
27
  const React = __importStar(require("react"));
28
28
  const decorateMapComponent_1 = __importStar(require("./decorateMapComponent"));
29
- const ProviderConstants = __importStar(require("./ProviderConstants"));
30
29
  class MapPolygon extends React.Component {
31
30
  getNativeComponent;
32
31
  getMapManagerCommand;
@@ -39,30 +38,10 @@ class MapPolygon extends React.Component {
39
38
  setNativeProps(props) {
40
39
  this.polygon.current?.setNativeProps(props);
41
40
  }
42
- updateNativeProps() {
43
- return () => {
44
- const { fillColor, strokeColor, strokeWidth } = this.props;
45
- let polygonNativeProps = {};
46
- if (fillColor) {
47
- polygonNativeProps.fillColor = fillColor;
48
- }
49
- if (strokeColor) {
50
- polygonNativeProps.strokeColor = strokeColor;
51
- }
52
- if (strokeWidth) {
53
- polygonNativeProps.strokeWidth = strokeWidth;
54
- }
55
- if (polygonNativeProps) {
56
- this.setNativeProps(polygonNativeProps);
57
- }
58
- };
59
- }
60
41
  render() {
61
42
  const { strokeColor = '#000', strokeWidth = 1 } = this.props;
62
43
  const AIRMapPolygon = this.getNativeComponent();
63
- return (<AIRMapPolygon {...this.props} strokeColor={strokeColor} strokeWidth={strokeWidth} ref={this.polygon} onLayout={this.context === ProviderConstants.PROVIDER_GOOGLE
64
- ? this.updateNativeProps()
65
- : undefined}/>);
44
+ return (<AIRMapPolygon {...this.props} strokeColor={strokeColor} strokeWidth={strokeWidth} ref={this.polygon}/>);
66
45
  }
67
46
  }
68
47
  exports.MapPolygon = MapPolygon;
package/lib/MapView.d.ts CHANGED
@@ -664,7 +664,6 @@ declare class MapView extends React.Component<MapViewProps, State> {
664
664
  */
665
665
  boundingBoxForRegion(region: Region): BoundingBox;
666
666
  private _mapManagerCommand;
667
- private _getHandle;
668
667
  private _runCommand;
669
668
  render(): JSX.Element;
670
669
  }
package/lib/MapView.js CHANGED
@@ -81,7 +81,7 @@ class MapView extends React.Component {
81
81
  }
82
82
  getCamera() {
83
83
  if (react_native_1.Platform.OS === 'android') {
84
- return react_native_1.NativeModules.AirMapModule.getCamera(this._getHandle());
84
+ return react_native_1.NativeModules.AirMapModule.getCamera(this.map.current);
85
85
  }
86
86
  else if (react_native_1.Platform.OS === 'ios') {
87
87
  return this._runCommand('getCamera', []);
@@ -128,7 +128,7 @@ class MapView extends React.Component {
128
128
  */
129
129
  async getMapBoundaries() {
130
130
  if (react_native_1.Platform.OS === 'android') {
131
- return await react_native_1.NativeModules.AirMapModule.getMapBoundaries(this._getHandle());
131
+ return await react_native_1.NativeModules.AirMapModule.getMapBoundaries(this.map.current);
132
132
  }
133
133
  else if (react_native_1.Platform.OS === 'ios') {
134
134
  return await this._runCommand('getMapBoundaries', []);
@@ -177,7 +177,7 @@ class MapView extends React.Component {
177
177
  }
178
178
  // Call native function
179
179
  if (react_native_1.Platform.OS === 'android') {
180
- return react_native_1.NativeModules.AirMapModule.takeSnapshot(this._getHandle(), config);
180
+ return react_native_1.NativeModules.AirMapModule.takeSnapshot(this.map.current, config);
181
181
  }
182
182
  else if (react_native_1.Platform.OS === 'ios') {
183
183
  return new Promise((resolve, reject) => {
@@ -212,7 +212,7 @@ class MapView extends React.Component {
212
212
  */
213
213
  addressForCoordinate(coordinate) {
214
214
  if (react_native_1.Platform.OS === 'android') {
215
- return react_native_1.NativeModules.AirMapModule.getAddressFromCoordinates(this._getHandle(), coordinate);
215
+ return react_native_1.NativeModules.AirMapModule.getAddressFromCoordinates(this.map.current, coordinate);
216
216
  }
217
217
  else if (react_native_1.Platform.OS === 'ios') {
218
218
  return this._runCommand('getAddressFromCoordinates', [coordinate]);
@@ -230,7 +230,7 @@ class MapView extends React.Component {
230
230
  */
231
231
  pointForCoordinate(coordinate) {
232
232
  if (react_native_1.Platform.OS === 'android') {
233
- return react_native_1.NativeModules.AirMapModule.pointForCoordinate(this._getHandle(), coordinate);
233
+ return react_native_1.NativeModules.AirMapModule.pointForCoordinate(this.map.current, coordinate);
234
234
  }
235
235
  else if (react_native_1.Platform.OS === 'ios') {
236
236
  return this._runCommand('pointForCoordinate', [coordinate]);
@@ -248,7 +248,7 @@ class MapView extends React.Component {
248
248
  */
249
249
  coordinateForPoint(point) {
250
250
  if (react_native_1.Platform.OS === 'android') {
251
- return react_native_1.NativeModules.AirMapModule.coordinateForPoint(this._getHandle(), point);
251
+ return react_native_1.NativeModules.AirMapModule.coordinateForPoint(this.map.current, point);
252
252
  }
253
253
  else if (react_native_1.Platform.OS === 'ios') {
254
254
  return this._runCommand('coordinateForPoint', [point]);
@@ -290,12 +290,9 @@ class MapView extends React.Component {
290
290
  _mapManagerCommand(name) {
291
291
  return react_native_1.NativeModules[`${(0, decorateMapComponent_1.getNativeMapName)(this.props.provider)}Manager`][name];
292
292
  }
293
- _getHandle() {
294
- return (0, react_native_1.findNodeHandle)(this.map.current);
295
- }
296
293
  _runCommand(name, args) {
297
294
  if (react_native_1.Platform.OS === 'ios') {
298
- return this._mapManagerCommand(name)(this._getHandle(), ...args);
295
+ return this._mapManagerCommand(name)(this.map.current, ...args);
299
296
  }
300
297
  else {
301
298
  return Promise.reject(`Invalid platform was passed: ${react_native_1.Platform.OS}`);
@@ -5,14 +5,14 @@ import { Camera, EdgePadding } from './MapView.types';
5
5
  import { LatLng, Region } from './sharedTypes';
6
6
  export declare type MapViewNativeComponentType = HostComponent<NativeProps>;
7
7
  interface NativeCommands {
8
- animateToRegion: (viewRef: React.RefObject<MapViewNativeComponentType>['current'], region: Region, duration: number) => void;
9
- setCamera: (viewRef: React.RefObject<MapViewNativeComponentType>['current'], camera: Partial<Camera>) => void;
10
- animateCamera: (viewRef: React.RefObject<MapViewNativeComponentType>['current'], camera: Partial<Camera>, duration: number) => void;
11
- fitToElements: (viewRef: React.RefObject<MapViewNativeComponentType>['current'], edgePadding: EdgePadding, animated: boolean) => void;
12
- fitToSuppliedMarkers: (viewRef: React.RefObject<MapViewNativeComponentType>['current'], markers: string[], edgePadding: EdgePadding, animated: boolean) => void;
13
- fitToCoordinates: (viewRef: React.RefObject<MapViewNativeComponentType>['current'], coordinates: LatLng[], edgePadding: EdgePadding, animated: boolean) => void;
14
- setMapBoundaries: (viewRef: React.RefObject<MapViewNativeComponentType>['current'], northEast: LatLng, southWest: LatLng) => void;
15
- setIndoorActiveLevelIndex: (viewRef: React.RefObject<MapViewNativeComponentType>['current'], activeLevelIndex: number) => void;
8
+ animateToRegion: (viewRef: NonNullable<React.RefObject<MapViewNativeComponentType>['current']>, region: Region, duration: number) => void;
9
+ setCamera: (viewRef: NonNullable<React.RefObject<MapViewNativeComponentType>['current']>, camera: Partial<Camera>) => void;
10
+ animateCamera: (viewRef: NonNullable<React.RefObject<MapViewNativeComponentType>['current']>, camera: Partial<Camera>, duration: number) => void;
11
+ fitToElements: (viewRef: NonNullable<React.RefObject<MapViewNativeComponentType>['current']>, edgePadding: EdgePadding, animated: boolean) => void;
12
+ fitToSuppliedMarkers: (viewRef: NonNullable<React.RefObject<MapViewNativeComponentType>['current']>, markers: string[], edgePadding: EdgePadding, animated: boolean) => void;
13
+ fitToCoordinates: (viewRef: NonNullable<React.RefObject<MapViewNativeComponentType>['current']>, coordinates: LatLng[], edgePadding: EdgePadding, animated: boolean) => void;
14
+ setMapBoundaries: (viewRef: NonNullable<React.RefObject<MapViewNativeComponentType>['current']>, northEast: LatLng, southWest: LatLng) => void;
15
+ setIndoorActiveLevelIndex: (viewRef: NonNullable<React.RefObject<MapViewNativeComponentType>['current']>, activeLevelIndex: number) => void;
16
16
  }
17
17
  export declare const Commands: NativeCommands;
18
18
  export {};
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.3.0-beta.1",
8
+ "version": "1.3.0-beta.2",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",