react-native-maps 0.29.0 → 0.29.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.29.3 - (August 29, 2021)
4
+
5
+ * Common: [#3920](https://github.com/react-native-maps/react-native-maps/pull/3920) GeoJSON onPress Crash Fix and Marker Customization Options
6
+ * Common: [#3930](https://github.com/react-native-maps/react-native-maps/pull/3930) Updated peer deps to maintain compatibility with expo init
7
+
8
+ ## 0.29.2 - (July 5, 2021)
9
+
10
+ * Android: **Revert** [#3797](https://github.com/react-native-maps/react-native-maps/pull/3797) Allow a previously dashed line to be made solid
11
+
12
+ ## 0.29.1 - (July 5, 2021)
13
+
14
+ * Common: [#3855](https://github.com/react-native-maps/react-native-maps/pull/3855) Fix crashes related to getAddressFromCoordinates for android and iOS
15
+ * Common: [#3871](https://github.com/react-native-maps/react-native-maps/pull/3871) Allow React 17 peer dependency
16
+
3
17
  ## 0.29.0 - (June 8, 2021)
4
18
 
5
19
  * Common: [#3779](https://github.com/react-native-maps/react-native-maps/pull/3779) Polyline tappable feature on GeoJson
package/README.md CHANGED
@@ -118,7 +118,7 @@ import { Marker } from 'react-native-maps';
118
118
  ```
119
119
 
120
120
  ### Rendering a Marker with a custom image
121
- 1. You need to generate an `png` image with various resolution (lets call them `custom_pin`) - for more infromation go to [Android](https://developer.android.com/studio/write/image-asset-studio#access), [iOS](https://developer.apple.com/library/archive/documentation/ToolsLanguages/Conceptual/Xcode_Overview/AddingImages.html)
121
+ 1. You need to generate an `png` image with various resolution (lets call them `custom_pin`) - for more information go to [Android](https://developer.android.com/studio/write/image-asset-studio#access), [iOS](https://developer.apple.com/library/archive/documentation/ToolsLanguages/Conceptual/Xcode_Overview/AddingImages.html)
122
122
  2. put all images in Android drawables and iOS assets dir
123
123
  3. Now you can use the following code:
124
124
  ```jsx
@@ -236,7 +236,7 @@ See [OSM Wiki](https://wiki.openstreetmap.org/wiki/Category:Tile_downloading) fo
236
236
 
237
237
  ### Overlaying other components on the map
238
238
 
239
- Place components you that wish to overlay `MapView` underneath the `MapView` closing tag. Absolutely position these elements.
239
+ Place components that you wish to overlay `MapView` underneath the `MapView` closing tag. Absolutely position these elements.
240
240
 
241
241
  ```jsx
242
242
  render() {
@@ -457,7 +457,7 @@ render() {
457
457
  Markers can also accept an `AnimatedRegion` value as a coordinate.
458
458
 
459
459
  ```jsx
460
- import Mapview, { AnimatedRegion, Marker } from 'react-native-maps';
460
+ import Mapview, { AnimatedRegion, MarkerAnimated } from 'react-native-maps';
461
461
 
462
462
  getInitialState() {
463
463
  return {
@@ -491,44 +491,7 @@ componentWillReceiveProps(nextProps) {
491
491
  render() {
492
492
  return (
493
493
  <MapView initialRegion={...}>
494
- <MapView.Marker.Animated
495
- ref={marker => { this.marker = marker }}
496
- coordinate={this.state.coordinate}
497
- />
498
- </MapView>
499
- );
500
- }
501
- ```
502
-
503
- If you need a smoother animation to move the marker on Android, you can modify the previous example:
504
-
505
- ```jsx
506
- // ...
507
-
508
- componentWillReceiveProps(nextProps) {
509
- const duration = 500
510
-
511
- if (this.props.coordinate !== nextProps.coordinate) {
512
- if (Platform.OS === 'android') {
513
- if (this.marker) {
514
- this.marker.animateMarkerToCoordinate(
515
- nextProps.coordinate,
516
- duration
517
- );
518
- }
519
- } else {
520
- this.state.coordinate.timing({
521
- ...nextProps.coordinate,
522
- duration
523
- }).start();
524
- }
525
- }
526
- }
527
-
528
- render() {
529
- return (
530
- <MapView initialRegion={...}>
531
- <Marker.Animated
494
+ <MarkerAnimated
532
495
  ref={marker => { this.marker = marker }}
533
496
  coordinate={this.state.coordinate}
534
497
  />
package/docs/geojson.md CHANGED
@@ -15,6 +15,7 @@
15
15
  | `miterLimit` | `Number` | | The limiting value that helps avoid spikes at junctions between connected line segments. The miter limit helps you avoid spikes in paths that use the `miter` `lineJoin` style. If the ratio of the miter length—that is, the diagonal length of the miter join—to the line thickness exceeds the miter limit, the joint is converted to a bevel join. The default miter limit is 10, which results in the conversion of miters whose angle at the joint is less than 11 degrees. |
16
16
  | `zIndex` | `Number` | | Layer level of the z-index value |
17
17
  | `onPress` | `Function` | | returns the selected overlay value with the onPress functionality |
18
+ | `markerComponent` | `React Node` | | Component to render in place of the default marker when the overlay type is a `point`
18
19
 
19
20
  ## Example
20
21
 
package/docs/marker.md CHANGED
@@ -7,7 +7,7 @@
7
7
  | `title` | `String` | | The title of the marker. This is only used if the <Marker /> component has no children that are a `<Callout />`, in which case the default callout behavior will be used, which will show both the `title` and the `description`, if provided.
8
8
  | `description` | `String` | | The description of the marker. This is only used if the <Marker /> component has no children that are a `<Callout />`, in which case the default callout behavior will be used, which will show both the `title` and the `description`, if provided.
9
9
  | `image` | `ImageSource`* | | A custom image to be used as the marker's icon. Only local image resources are allowed to be used.
10
- | `icon` | `ImageSource`* | | Marker icon to render (equivalent to `icon` property of GMSMarker Class). **Note:** Google maps only!
10
+ | `icon` | `ImageSource`* | | Marker icon to render (equivalent to `icon` property of GMSMarker Class). Only local image resources are allowed to be used. **Note:** Google maps only!
11
11
  | `pinColor` | `Color` | | If no custom marker view or custom image is provided, the platform default pin will be used, which can be customized by this color. Ignored if a custom marker is being used.<br/><br/> For Android, the set of available colors is limited. Unsupported colors will fall back to red. See [#887](https://github.com/react-community/react-native-maps/issues/887) for more information.
12
12
  | `coordinate` | `LatLng` | | The coordinate for the marker.
13
13
  | `centerOffset` | `Point` | (0, 0) | The offset (in points) at which to display the view.<br/><br/> By default, the center point of an annotation view is placed at the coordinate point of the associated annotation. You can use this property to reposition the annotation view as needed. This x and y offset values are measured in points. Positive offset values move the annotation view down and to the right, while negative values move it up and to the left.<br/><br/> For Google Maps, see the `anchor` prop.
@@ -72,7 +72,7 @@ type Point {
72
72
 
73
73
  ## Children Components
74
74
 
75
- Children components can be added within a Marker and rendered content will replace the marker symbol. This is a way of creating custom markers and allowing use of native SVGs.
75
+ Children components can be added within a Marker and rendered content will replace the marker symbol. This is a way of creating custom markers and allowing use of native SVGs.
76
76
 
77
77
  Example:
78
78
  ```
package/index.d.ts CHANGED
@@ -265,6 +265,7 @@ declare module 'react-native-maps' {
265
265
  compassOffset?: { x: number; y: number };
266
266
  tintColor?: string;
267
267
 
268
+ onMapLoaded?: () => void;
268
269
  onMapReady?: () => void;
269
270
  onKmlReady?: (values: KmlMapEvent) => void;
270
271
  onRegionChange?: (region: Region, details?: { isGesture: boolean }) => void;
@@ -592,6 +593,9 @@ declare module 'react-native-maps' {
592
593
  lineCap?: 'butt' | 'round' | 'square';
593
594
  lineJoin?: 'miter' | 'round' | 'bevel';
594
595
  miterLimit?: number;
596
+ zIndex?: number;
597
+ onPress?: (event: MapEvent) => void;
598
+ markerComponent?: React.ReactNode
595
599
  }
596
600
 
597
601
  export class Geojson extends React.Component<GeojsonProps, any> {}
@@ -212,6 +212,10 @@ public class AirMapModule extends ReactContextBaseJavaModule {
212
212
  try {
213
213
  List<Address> list =
214
214
  geocoder.getFromLocation(coordinate.getDouble("latitude"),coordinate.getDouble("longitude"),1);
215
+ if (list.isEmpty()) {
216
+ promise.reject("Can not get address location");
217
+ return;
218
+ }
215
219
  Address address = list.get(0);
216
220
 
217
221
  WritableMap addressJson = new WritableNativeMap();
@@ -100,7 +100,6 @@ public class AirMapPolyline extends AirMapFeature {
100
100
 
101
101
  private void applyPattern() {
102
102
  if(patternValues == null) {
103
- polyline.setPattern(null);
104
103
  return;
105
104
  }
106
105
  this.pattern = new ArrayList<>(patternValues.size());
@@ -1,7 +1,171 @@
1
1
  import React from 'react';
2
+ import PropTypes from 'prop-types';
2
3
  import Marker from './MapMarker';
3
4
  import Polyline from './MapPolyline';
4
5
  import Polygon from './MapPolygon';
6
+ import { ColorPropType } from 'react-native';
7
+
8
+ const propTypes = {
9
+ /**
10
+ * [Geojson](https://geojson.org/) description of object.
11
+ */
12
+ geojson: PropTypes.object.isRequired,
13
+
14
+ /**
15
+ * The stroke color to use for the path.
16
+ */
17
+ strokeColor: ColorPropType,
18
+
19
+ /**
20
+ * The fill color to use for the path.
21
+ */
22
+ fillColor: ColorPropType,
23
+
24
+ /**
25
+ * The stroke width to use for the path.
26
+ */
27
+ strokeWidth: PropTypes.number,
28
+
29
+ /**
30
+ * The offset (in points) at which to start drawing the dash pattern.
31
+ *
32
+ * Use this property to start drawing a dashed line partway through a segment or gap. For
33
+ * example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the
34
+ * middle of the first gap.
35
+ *
36
+ * The default value of this property is 0.
37
+ *
38
+ * @platform ios
39
+ */
40
+ lineDashPhase: PropTypes.number,
41
+
42
+ /**
43
+ * An array of numbers specifying the dash pattern to use for the path.
44
+ *
45
+ * The array contains one or more numbers that indicate the lengths (measured in points) of the
46
+ * line segments and gaps in the pattern. The values in the array alternate, starting with the
47
+ * first line segment length, followed by the first gap length, followed by the second line
48
+ * segment length, and so on.
49
+ *
50
+ * This property is set to `null` by default, which indicates no line dash pattern.
51
+ *
52
+ * @platform ios
53
+ */
54
+ lineDashPattern: PropTypes.arrayOf(PropTypes.number),
55
+
56
+ /**
57
+ * The line cap style to apply to the open ends of the path.
58
+ * The default style is `round`.
59
+ *
60
+ * @platform ios
61
+ */
62
+ lineCap: PropTypes.oneOf(['butt', 'round', 'square']),
63
+
64
+ /**
65
+ * The line join style to apply to corners of the path.
66
+ * The default style is `round`.
67
+ *
68
+ * @platform ios
69
+ */
70
+ lineJoin: PropTypes.oneOf(['miter', 'round', 'bevel']),
71
+
72
+ /**
73
+ * The limiting value that helps avoid spikes at junctions between connected line segments.
74
+ * The miter limit helps you avoid spikes in paths that use the `miter` `lineJoin` style. If
75
+ * the ratio of the miter length—that is, the diagonal length of the miter join—to the line
76
+ * thickness exceeds the miter limit, the joint is converted to a bevel join. The default
77
+ * miter limit is 10, which results in the conversion of miters whose angle at the joint
78
+ * is less than 11 degrees.
79
+ *
80
+ * @platform ios
81
+ */
82
+ miterLimit: PropTypes.number,
83
+
84
+ /**
85
+ * The order in which this tile overlay is drawn with respect to other overlays. An overlay
86
+ * with a larger z-index is drawn over overlays with smaller z-indices. The order of overlays
87
+ * with the same z-index is arbitrary. The default zIndex is 0.
88
+ *
89
+ * @platform android
90
+ */
91
+ zIndex: PropTypes.number,
92
+
93
+ /**
94
+ * Callback that is called when the user presses on the polygon
95
+ */
96
+ onPress: PropTypes.func,
97
+
98
+ /**
99
+ * Component to render in place of the default marker when the overlay type is a `point`
100
+ *
101
+ */
102
+ markerComponent: PropTypes.node,
103
+ };
104
+
105
+ const Geojson = props => {
106
+ const overlays = makeOverlays(props.geojson.features);
107
+ return (
108
+ <React.Fragment>
109
+ {overlays.map((overlay, index) => {
110
+ const fillColor = getColor(props, overlay, 'fill', 'fillColor');
111
+ const strokeColor = getColor(props, overlay, 'stroke', 'strokeColor');
112
+ const markerColor = getColor(props, overlay, 'marker-color', 'color');
113
+ const strokeWidth = getStrokeWidth(props, overlay);
114
+ if (overlay.type === 'point') {
115
+ return (
116
+ <Marker
117
+ key={index}
118
+ coordinate={overlay.coordinates}
119
+ image={props.image}
120
+ pinColor={markerColor}
121
+ zIndex={props.zIndex}
122
+ onPress={() => props.onPress && props.onPress(overlay)}
123
+ >
124
+ {props.markerComponent}
125
+ </Marker>
126
+ );
127
+ }
128
+ if (overlay.type === 'polygon') {
129
+ return (
130
+ <Polygon
131
+ key={index}
132
+ coordinates={overlay.coordinates}
133
+ holes={overlay.holes}
134
+ strokeColor={strokeColor}
135
+ fillColor={fillColor}
136
+ strokeWidth={strokeWidth}
137
+ tappable={props.tappable}
138
+ onPress={() => props.onPress && props.onPress(overlay)}
139
+ zIndex={props.zIndex}
140
+ />
141
+ );
142
+ }
143
+ if (overlay.type === 'polyline') {
144
+ return (
145
+ <Polyline
146
+ key={index}
147
+ coordinates={overlay.coordinates}
148
+ strokeColor={strokeColor}
149
+ strokeWidth={strokeWidth}
150
+ lineDashPhase={props.lineDashPhase}
151
+ lineDashPattern={props.lineDashPattern}
152
+ lineCap={props.lineCap}
153
+ lineJoin={props.lineJoin}
154
+ miterLimit={props.miterLimit}
155
+ zIndex={props.zIndex}
156
+ tappable={props.tappable}
157
+ onPress={() => props.onPress && props.onPress(overlay)}
158
+ />
159
+ );
160
+ }
161
+ })}
162
+ </React.Fragment>
163
+ );
164
+ };
165
+
166
+ Geojson.propTypes = propTypes;
167
+
168
+ export default Geojson;
5
169
 
6
170
  export const makeOverlays = features => {
7
171
  const points = features
@@ -141,64 +305,3 @@ const getStrokeWidth = (props, overlay) => {
141
305
  }
142
306
  return 0;
143
307
  };
144
-
145
- const Geojson = props => {
146
- const overlays = makeOverlays(props.geojson.features);
147
- return (
148
- <React.Fragment>
149
- {overlays.map((overlay, index) => {
150
- const fillColor = getColor(props, overlay, 'fill', 'fillColor');
151
- const strokeColor = getColor(props, overlay, 'stroke', 'strokeColor');
152
- const markerColor = getColor(props, overlay, 'marker-color', 'color');
153
- const strokeWidth = getStrokeWidth(props, overlay);
154
- if (overlay.type === 'point') {
155
- return (
156
- <Marker
157
- key={index}
158
- coordinate={overlay.coordinates}
159
- image={props.image}
160
- pinColor={markerColor}
161
- zIndex={props.zIndex}
162
- onPress={() => props.onPress(overlay)}
163
- />
164
- );
165
- }
166
- if (overlay.type === 'polygon') {
167
- return (
168
- <Polygon
169
- key={index}
170
- coordinates={overlay.coordinates}
171
- holes={overlay.holes}
172
- strokeColor={strokeColor}
173
- fillColor={fillColor}
174
- strokeWidth={strokeWidth}
175
- tappable={props.tappable}
176
- onPress={() => props.onPress(overlay)}
177
- zIndex={props.zIndex}
178
- />
179
- );
180
- }
181
- if (overlay.type === 'polyline') {
182
- return (
183
- <Polyline
184
- key={index}
185
- coordinates={overlay.coordinates}
186
- strokeColor={strokeColor}
187
- strokeWidth={strokeWidth}
188
- lineDashPhase={props.lineDashPhase}
189
- lineDashPattern={props.lineDashPattern}
190
- lineCap={props.lineCap}
191
- lineJoin={props.lineJoin}
192
- miterLimit={props.miterLimit}
193
- zIndex={props.zIndex}
194
- tappable={props.tappable}
195
- onPress={() => props.onPress(overlay)}
196
- />
197
- );
198
- }
199
- })}
200
- </React.Fragment>
201
- );
202
- };
203
-
204
- export default Geojson;
@@ -575,7 +575,7 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
575
575
  if (![view isKindOfClass:[AIRMap class]]) {
576
576
  reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid view returned from registry, expecting AIRMap, got: %@", view], NULL);
577
577
  } else {
578
- if (coordinate != nil ||
578
+ if (coordinate == nil ||
579
579
  ![[coordinate allKeys] containsObject:@"latitude"] ||
580
580
  ![[coordinate allKeys] containsObject:@"longitude"]) {
581
581
  reject(@"Invalid argument", [NSString stringWithFormat:@"Invalid coordinate format"], NULL);
@@ -599,6 +599,8 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
599
599
  @"countryCode" : [NSString stringWithFormat:@"%@", placemark.ISOcountryCode],
600
600
  @"country" : [NSString stringWithFormat:@"%@", placemark.country],
601
601
  });
602
+ } else {
603
+ reject(@"Invalid argument", [NSString stringWithFormat:@"Can not get address location"], NULL);
602
604
  }
603
605
  }];
604
606
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "React Native Mapview component for iOS + Android",
4
4
  "main": "index.js",
5
5
  "author": "Leland Richardson <leland.m.richardson@gmail.com>",
6
- "version": "0.29.0",
6
+ "version": "0.29.4",
7
7
  "scripts": {
8
8
  "lint": "./node_modules/eslint/bin/eslint.js .",
9
9
  "ci": "npm run lint"
@@ -22,9 +22,9 @@
22
22
  "mapkit"
23
23
  ],
24
24
  "peerDependencies": {
25
- "react": ">= 16.0 || < 17.0",
25
+ "react": ">= 16.0 || < 18.0",
26
26
  "react-native": ">= 0.51",
27
- "react-native-web": "^0.11"
27
+ "react-native-web": ">= 0.11"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@react-native-community/eslint-config": "0.0.5",
@@ -1,18 +0,0 @@
1
- ---
2
- name: "\U0001F914 Questions and help"
3
- about: Use this if there is something not clear about the code or its docs.
4
- title: ''
5
- labels: question
6
- assignees: ''
7
-
8
- ---
9
-
10
- # Question
11
-
12
- <!--
13
- Before submitting it, please ensure that this was not already asked in another issue, or on StackOverflow. Ideally, you should always refer to StackOverflow first.
14
-
15
- This issue should serve for you to ask a question about the library to the maintainers and other fellow developers - remember that even if the issue gets closed, the conversation can move forward 🤗
16
-
17
- Also, ideally this issue should culminate in a PR to the documentation for this library so that future developers will have that doubt cleared.
18
- -->