Skip to content

Commit 6a9eba0

Browse files
Merge branch 'master' into fix_crash_for_airmap_reference
* master: (31 commits) Wider Note column (prevent horisontal scroll) (react-native-maps#3130) replaced deprecated bridge.imageLoader calls with moduleForClass API (react-native-maps#3125) Implement onUserLocationChange in AIRMap (react-native-maps#2889) keep current mapType when taking snapshot (react-native-maps#3120) Add mapPadding on iOS maps (react-native-maps#3119) [iOS] Expose isAccessibilityElement as a prop (react-native-maps#3115) Add supportLibVersion safeguard in gradle build (react-native-maps#3106) [0.26.1] Release rn 0.60.5 support (react-native-maps#3020) "AIRMap" was not found in the UIManager IN "0.26.0" (react-native-maps#3103) [0.26.0] Release Add Heatmap back in (react-native-maps#3064) Fixes NPE while removing already removed marker. (react-native-maps#3032) Add flat property binding on Marker for iOS (react-native-maps#3051) Add heading to the onUserLocationChange listener (react-native-maps#3045) Add onDoublePress callback (react-native-maps#2937) Allow using onPanDrag while scrollEnabled=true (react-native-maps#2935) updating pods for compile error (react-native-maps#3011) add overlay onPress event (react-native-maps#3007) Fix playServicesVersion name in installation docs (react-native-maps#3016) ...
2 parents e47f2da + 348b1ec commit 6a9eba0

50 files changed

Lines changed: 1500 additions & 94 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
# Change Log
2+
## 0.26.1 (October 3, 2019)
3+
4+
* Android: [#3103](https://github.com/react-native-community/react-native-maps/pull/3103) Support for RN 0.60.5
5+
* Android: [#3103](https://github.com/react-native-community/react-native-maps/pull/3103) "AIRMap" was not found in the UIManager
6+
7+
## 0.26.0 (September 30, 2019)
8+
9+
* iOS: [#2999](https://github.com/react-native-community/react-native-maps/pull/2999) Update GoogleMaps pod to 3.2.0
10+
* iOS: [#2395](https://github.com/react-native-community/react-native-maps/pull/2395) Allow using onPanDrag while scrollEnabled=true
11+
* iOS: [#3051](https://github.com/react-native-community/react-native-maps/pull/3051) Add flat property binding on Marker for iOS
12+
* Android: [#3007](https://github.com/react-native-community/react-native-maps/pull/3007) Add Overlay onPress event
13+
* Android: [#3001](https://github.com/react-native-community/react-native-maps/pull/3001) Add @ReactModule annotation to help turbo modules processor
14+
* Common: [#3045](https://github.com/react-native-community/react-native-maps/pull/3045) Add heading to the onUserLocationChange listener
15+
* Common: [#2937](https://github.com/react-native-community/react-native-maps/pull/2937) Add onDoublePress callback
16+
* Common: [#2960](https://github.com/react-native-community/react-native-maps/pull/2959) Heatmaps for Android and iOS
17+
* Common: [#2959](https://github.com/react-native-community/react-native-maps/pull/2959) Added GeoJSON support by default
18+
* Common: [#2975](https://github.com/react-native-community/react-native-maps/pull/2975) Convert to new react native config format (RN 0.60)
19+
* Common: [#2973](https://github.com/react-native-community/react-native-maps/pull/2973) Fix select annotation when show/hide callout view
220

321
## 0.25.0 (July 11, 2019)
422
* Android: [#2941](https://github.com/react-native-community/react-native-maps/pull/2941) Fix build gradle to allow jettifier to run correctly

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ versions you should add `react` as a dependency in your `package.json`.
3838

3939
[`<Overlay />` Component API](docs/overlay.md)
4040

41+
[`<Heatmap />` Component API](docs/heatmap.md)
42+
43+
[`<Geojson />` Component API](docs/geojson.md)
44+
4145
## General Usage
4246

4347
```js

docs/geojson.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# `<Geojson />` Component API
2+
3+
## Props
4+
5+
| Prop | Type | Default | Note |
6+
| --------- | ---- | ------------------------------------------------------ | ---- |
7+
| `geojson` | | [Geojson](https://geojson.org/) description of object. |
8+
9+
## Example
10+
11+
```
12+
import React from 'react';
13+
import MapView, {Geojson} from 'react-native-maps';
14+
15+
const myPlace = {
16+
type: 'FeatureCollection',
17+
features: [
18+
{
19+
type: 'Feature',
20+
properties: {},
21+
geometry: {
22+
type: 'Point',
23+
coordinates: [64.165329, 48.844287],
24+
}
25+
}
26+
]
27+
};
28+
29+
const Map = props => (
30+
<MapView>
31+
<Geojson geojson={myPlace} />
32+
</MapView>
33+
);
34+
```
35+
36+

docs/heatmap.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# `<Heatmap />` Component API
2+
3+
## Props
4+
5+
| Prop | Type | Default | Note |
6+
|---|---|---|---|
7+
| `points` | `Array<WeightedLatLng>` | | Array of heatmap entries to apply towards density.
8+
| `radius` | `Number` | `20` | The radius of the heatmap points in pixels, between 10 and 50.
9+
| `opacity` | `Number` | `0.7` | The opacity of the heatmap.
10+
| `gradient` | `Object` | | Heatmap gradient configuration (See below for *Gradient Config*).
11+
12+
13+
## Gradient Config
14+
15+
[Android Doc](https://developers.google.com/maps/documentation/android-sdk/utility/heatmap#custom) | [iOS Doc](https://developers.google.com/maps/documentation/ios-sdk/utility/heatmap#customize)
16+
17+
| Prop | Type | Default | Note |
18+
|---|---|---|---|
19+
| `colors` | `Array<String>` | | Colors (one or more) to use for gradient.
20+
| `startPoints` | `Array<Number>` | | Array of floating point values from 0 to 1 representing where each color starts. Array length must be equal to `colors` array length.
21+
| `colorMapSize` | `Number` | `256` | Resolution of color map -- number corresponding to the number of steps colors are interpolated into.
22+
23+
24+
## Types
25+
26+
```
27+
type WeightedLatLng = {
28+
latitude: Number;
29+
longitude: Number;
30+
weight?: Number;
31+
}
32+
```

docs/installation.md

Lines changed: 82 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,46 @@
33
Install the library from npm:
44

55
```sh
6-
npm install react-native-maps --save
6+
npm install react-native-maps --save-exact
7+
yarn add react-native-maps -E
78
```
89

910
The library ships with platform native code that needs to be compiled
1011
together with React Native. This requires you to configure your build
1112
tools.
1213

14+
Since React Native 0.60 and higher, [autolinking](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md) makes the installation process simpler.
15+
1316
The actual map implementation depends on the platform. On Android, one
1417
has to use [Google
1518
Maps](https://developers.google.com/maps/documentation/), which in turn
16-
requires you to obtain an API key for the [Android
19+
requires you to obtain an [API key for the Android
1720
SDK](https://developers.google.com/maps/documentation/android-sdk/signup).
1821

1922
On iOS, one can choose between Google Maps or the native [Apple
2023
Maps](https://developer.apple.com/documentation/mapkit/) implementation.
2124

22-
When using Google Maps on iOS, you need to also register for the [iOS
25+
When using Google Maps on iOS, you need also to obtain an [API key for the iOS
2326
SDK](https://developers.google.com/maps/documentation/ios-sdk/get-api-key)
2427
and include the Google Maps library in your build. The native Apple Maps
2528
based implementation works out-of-the-box and is therefore simpler to
2629
use at the price of missing some of the features supported by the Google
2730
Maps backend.
2831

32+
> **WARNING**: Before you can start using the Google Maps Platform APIs and SDKs, you must sign up and create a [billing account](https://developers.google.com/maps/gmp-get-started#create-billing-account)!
33+
34+
---
35+
2936
## Build configuration on iOS
3037

31-
### Using React Native Link
38+
### Using React Native Link (React Native 0.59 and lower)
3239

3340
Run `react-native link react-native-maps` after which you should be able
3441
to use this library on iOS. Note that by default this will use Apple
3542
Maps and you will miss some of the features provided by Google (see the
3643
instruction on manually enabling Google Maps below).
3744

38-
### Using CocoaPods
45+
### Using CocoaPods (React Native 0.59 and lower)
3946

4047
> If the CocoaPods package manager is new to you, please first review
4148
> its [installation guide](https://guides.cocoapods.org/using/getting-started.html)
@@ -108,7 +115,14 @@ pod install
108115

109116
and open the produced workspace file (`.xcworkspace`) in XCode to build your project.
110117

111-
### Enabling Google Maps on iOS
118+
### Using CocoaPods (React Native 0.60 and higher)
119+
120+
```sh
121+
cd ios
122+
pod install
123+
```
124+
125+
### Enabling Google Maps on iOS (React Native all versions)
112126

113127
If you want to enable Google Maps on iOS, obtain the Google API key and
114128
edit your `AppDelegate.m` as follows:
@@ -127,57 +141,58 @@ edit your `AppDelegate.m` as follows:
127141
128142
The `[GMSServices provideAPIKey]` should be the **first call** of the method.
129143
130-
Then, do either of the following
144+
Then, do either of the following:
131145
132-
1. If you are using CocoaPods to manage your dependecies, uncomment the
146+
a) (React Native 0.59 and lower) If you are using CocoaPods to manage your dependecies, uncomment the
133147
lines related to Google Maps from the `Podfile` and run `pod install`.
134148
135-
2. If you used React Native link, you may include Google Maps manually as a
149+
b) (React Native 0.59 and lower) If you used React Native link, you may include Google Maps manually as a
136150
XCode framework following the instructions from [SDK docs -> Install
137151
manually](https://developers.google.com/maps/documentation/ios-sdk/start). Then, to link this library to the framework, add the following to your
138152
`package.json` and replace the
139153
`REPLACE_ME_RELATIVE_PATH_TO_GOOGLE_MAPS_INSTALL` with the relative path
140154
from your project root to the directory in which you installed the
141155
Google Maps frameworks. You might need to specify a recursive search path
142-
by adding a `/**` at the end of the provided path (e.g. `"./node_modules/react-native-maps/enable-google-maps 'ios/my-frameworks/GoogleMaps/**'"
143-
144-
```json
145-
{
146-
"name": "your-app",
147-
"scripts": {
148-
"postinstall": "./node_modules/react-native-maps/enable-google-maps REPLACE_ME_RELATIVE_PATH_TO_GOOGLE_MAPS_INSTALL"
149-
}
150-
}
151-
```
152-
153-
Re-run `npm install` or `yarn` to ensure the `postinstall` script is run.
154-
155-
3. Import and add `{PROVIDER_GOOGLE}` to your JavaScript:
156-
```javascript
157-
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
158-
...
159-
160-
<MapView
161-
provider={PROVIDER_GOOGLE}
162-
style={styles.map}
163-
...
164-
>
165-
166-
```
156+
by adding a `/**` at the end of the provided path (e.g. "./node_modules/react-native-maps/enable-google-maps 'ios/my-frameworks/GoogleMaps/**'"
157+
158+
```json
159+
{
160+
"name": "your-app",
161+
"scripts": {
162+
"postinstall": "./node_modules/react-native-maps/enable-google-maps REPLACE_ME_RELATIVE_PATH_TO_GOOGLE_MAPS_INSTALL"
163+
}
164+
}
165+
```
166+
167+
Re-run `npm install` or `yarn` to ensure the `postinstall` script is run.
168+
169+
c) (React Native 0.60 and higher) Add the following to your Podfile above the `use_native_modules!` function and run `pod install` in the ios folder:
170+
```ruby
171+
# React Native Maps dependencies
172+
rn_maps_path = '../node_modules/react-native-maps'
173+
pod 'react-native-google-maps', :path => rn_maps_path
174+
pod 'GoogleMaps'
175+
pod 'Google-Maps-iOS-Utils'
176+
```
177+
178+
That's it, you made it! 👍
179+
180+
---
181+
167182

168183
## Build configuration on Android
169184

170185
Ensure your build files match the following requirements:
171186

172-
1. Define the `react-native-maps` project in `android/settings.gradle`:
187+
1. (React Native 0.59 and lower) Define the `react-native-maps` project in `android/settings.gradle`:
173188

174189
```groovy
175190
...
176191
include ':react-native-maps'
177192
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
178193
```
179194

180-
2. Add the `react-native-maps` as an dependency of your app in `android/app/build.gradle`:
195+
2. (React Native 0.59 and lower) Add the `react-native-maps` as an dependency of your app in `android/app/build.gradle`:
181196

182197
```groovy
183198
...
@@ -187,7 +202,7 @@ dependencies {
187202
}
188203
```
189204

190-
If you've defined *[project-wide
205+
3.1 (React Native all versions) If you've defined *[project-wide
191206
properties](https://developer.android.com/studio/build/gradle-tips.html)*
192207
(**recommended**) in your root `build.gradle`, this library will detect
193208
the presence of the following properties:
@@ -200,16 +215,32 @@ allprojects {...}
200215
+ Project-wide Gradle configuration properties
201216
*/
202217
ext {
203-
compileSdkVersion = 26
204-
targetSdkVersion = 26
205-
buildToolsVersion = "26.0.2"
206-
supportLibVersion = "26.1.0"
207-
googlePlayServicesVersion = "16.1.0" // or set latest version
208-
androidMapsUtilsVersion = "0.5+"
218+
compileSdkVersion = xxx
219+
targetSdkVersion = xxx
220+
buildToolsVersion = "xxx"
221+
minSdkVersion = xxx
222+
supportLibVersion = "xxx"
223+
playServicesVersion = "xxx" // or set latest version
224+
androidMapsUtilsVersion = "xxx"
225+
}
226+
```
227+
or do
228+
```
229+
buildscript {
230+
ext {
231+
buildToolsVersion = "xxx"
232+
minSdkVersion = xxx
233+
compileSdkVersion = xxx
234+
targetSdkVersion = xxx
235+
supportLibVersion = "xxx"
236+
playServicesVersion = "xxx" // or set latest version
237+
androidMapsUtilsVersion = "xxx"
238+
}
209239
}
240+
...
210241
```
211242

212-
If you do **not** have *project-wide properties* defined and have a
243+
3.2 (React Native all versions) If you do **not** have *project-wide properties* defined and have a
213244
different play-services version than the one included in this library,
214245
use the following instead (switch 10.0.1 for the desired version):
215246

@@ -226,7 +257,7 @@ dependencies {
226257
}
227258
```
228259

229-
3. Specify your Google Maps API Key:
260+
4. (React Native all versions) Specify your Google Maps API Key:
230261

231262
Add your API key to your manifest file (`android/app/src/main/AndroidManifest.xml`):
232263

@@ -250,7 +281,7 @@ dependencies {
250281
251282
Source: https://developers.google.com/maps/documentation/android-api/signup
252283

253-
4. Add `import com.airbnb.android.react.maps.MapsPackage;` and `new MapsPackage()` in your `MainApplication.java` :
284+
5. (React Native 0.59 and lower) Add `import com.airbnb.android.react.maps.MapsPackage;` and `new MapsPackage()` in your `MainApplication.java` :
254285

255286
```java
256287
import com.airbnb.android.react.maps.MapsPackage;
@@ -264,14 +295,18 @@ import com.airbnb.android.react.maps.MapsPackage;
264295
}
265296
```
266297

267-
5. Ensure that you have Google Play Services installed:
298+
6. (React Native all versions) Ensure that you have Google Play Services installed:
268299

269300
* For the Genymotion emulator, you can follow [these instructions](https://www.genymotion.com/help/desktop/faq/#google-play-services).
270301
* For a physical device you need to search on Google for 'Google Play
271302
Services'. There will be a link that takes you to the Play Store and
272303
from there you will see a button to update it (do not search within the
273304
Play Store).
274305

306+
That's it, you made it! :+1:
307+
308+
---
309+
275310
## Troubleshooting
276311

277312
### The map background is blank (Google Maps)

docs/mapview.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
| `initialRegion` | `Region` | | The initial region to be displayed by the map. Use this prop instead of `region` only if you don't want to control the viewport of the map besides the initial region.<br/><br/> Changing this prop after the component has mounted will not result in a region change.<br/><br/> This is similar to the `initialValue` prop of a text input.
1010
| `camera` | `Camera` | | The camera view the map should display. If you use this, the `region` property is ignored.
1111
| `initialCamera` | `Camera` | | Like `initialRegion`, use this prop instead of `camera` only if you don't want to control the viewport of the map besides the initial camera setting.<br/><br/> Changing this prop after the component has mounted will not result in a region change.<br/><br/> This is similar to the `initialValue` prop of a text input.
12-
| `mapPadding` | `EdgePadding` | | Adds custom padding to each side of the map. Useful when map elements/markers are obscured. **Note** Google Maps only.
13-
| `paddingAdjustmentBehavior` | 'always'\|'automatic'\|'never' | 'never' | Indicates how/when to affect padding with safe area insets (`GoogleMaps` in iOS only)
12+
| `mapPadding` | `EdgePadding` | | Adds custom padding to each side of the map. Useful when map elements/markers are obscured.
13+
| `paddingAdjustmentBehavior` | 'always' \| 'automatic' \| 'never' | 'never' | Indicates how/when to affect padding with safe area insets (`GoogleMaps` in iOS only)
1414
| `liteMode` | `Boolean` | `false` | Enable lite mode. **Note**: Android only.
1515
| `mapType` | `String` | `"standard"` | The map type to be displayed. <br/><br/> - standard: standard road map (default)<br/> - none: no map **Note** Not available on MapKit<br/> - satellite: satellite view<br/> - hybrid: satellite view with roads and points of interest overlayed<br/> - terrain: (Android only) topographic view<br/> - mutedStandard: more subtle, makes markers/lines pop more (iOS 11.0+ only)
1616
| `customMapStyle` | `Array` | | Adds custom styling to the map component. See [README](https://github.com/react-native-community/react-native-maps#customizing-the-map-style) for more information.
@@ -42,6 +42,7 @@
4242
| `legalLabelInsets` | `EdgeInsets` | | If set, changes the position of the "Legal" label link from the OS default. **Note:** iOS only.
4343
| `kmlSrc` | `string` | | The URL from KML file. **Note:** Google Maps and Markers only (either Android or iOS with `PROVIDER_GOOGLE`).
4444
| `compassOffset` | `Point` | | If set, changes the position of the compass. **Note:** iOS Maps only.
45+
| `isAccessibilityElement` | `Boolean` | `false` | Determines whether the MapView captures VoiceOver touches or forwards them to children. When `true`, map markers are not visible to VoiceOver. **Note:** iOS Maps only.
4546

4647

4748
## Events
@@ -54,8 +55,9 @@ To access event data, you will need to use `e.nativeEvent`. For example, `onPres
5455
| `onKmlReady` | `KmlContainer` | Callback that is called once the kml is fully loaded.
5556
| `onRegionChange` | `Region` | Callback that is called continuously when the region changes, such as when a user is dragging the map.
5657
| `onRegionChangeComplete` | `Region` | Callback that is called once when the region changes, such as when the user is done moving the map.
57-
| `onUserLocationChange` | `{ coordinate: Location }` | Callback that is called when the underlying map figures our users current location (coordinate also includes isFromMockProvider value for Android API 18 and above). Make sure **showsUserLocation** is set to *true* and that the provider is `"google"`.
58+
| `onUserLocationChange` | `{ coordinate: Location }` | Callback that is called when the underlying map figures our users current location (coordinate also includes isFromMockProvider value for Android API 18 and above). Make sure **showsUserLocation** is set to *true*.
5859
| `onPress` | `{ coordinate: LatLng, position: Point }` | Callback that is called when user taps on the map.
60+
| `onDoublePress` | `{ coordinate: LatLng, position: Point }` | Callback that is called when user double taps on the map.
5961
| `onPanDrag` | `{ coordinate: LatLng, position: Point }` | Callback that is called when user presses and drags the map. **NOTE**: for iOS `scrollEnabled` should be set to false to trigger the event
6062
| `onPoiClick` | `{ coordinate: LatLng, position: Point, placeId: string, name: string }` | Callback that is called when user click on a POI.
6163
| `onLongPress` | `{ coordinate: LatLng, position: Point }` | Callback that is called when user makes a "long press" somewhere on the map.

docs/overlay.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
|---|---|---|---|
77
| `image` | `ImageSource` | A custom image to be used as the overlay. Only required local image resources and uri (as for images located in the net) are allowed to be used.
88
| `bounds` | `Array<LatLng>` | | The coordinates for the image (left-top corner, right-bottom corner). ie.```[[lat, long], [lat, long]]```
9+
| `tappable` | `Bool` | `false` | `Android only` Boolean to allow an overlay to be tappable and use the onPress function.
10+
11+
## Events
12+
13+
| Event Name | Returns | Notes
14+
|---|---|---|
15+
| `onPress` | | `Android only` Callback that is called when the user presses on the overlay
916

1017
## Types
1118

0 commit comments

Comments
 (0)