Skip to content
This repository was archived by the owner on Sep 4, 2021. It is now read-only.

Commit ca401f2

Browse files
committed
update documentation
switch to es5 (not all es6 features are supported on RN)
1 parent a383e62 commit ca401f2

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,21 @@ Geocoder.geocodeAddress('New York').then(res => {
7878
.catch(err => console.log(err))
7979
```
8080

81+
## Fallback to google maps geocoding
82+
83+
Geocoding services might not be included in some Android devices (Kindle, some 4.1 devices, non-google devices). For those special cases the lib can fallback to the [online google maps geocoding service](https://developers.google.com/maps/documentation/geocoding/intro#Geocoding)
84+
85+
```js
86+
import Geocoder from 'react-native-geocoder';
87+
// simply add your google key
88+
Geocoder.fallbackToGoogle(MY_KEY);
89+
90+
// use the lib as usual
91+
let ret = await Geocoder.geocodePosition({lat, lng})
92+
// you get the same results
93+
94+
```
95+
8196
## With async / await
8297
```
8398
try {

circle.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
11
machine:
22
node:
33
version: 5.11.1
4-
dependencies:
5-
cache_directories:
6-
- "node_modules"
7-
- "e2e/GeocoderE2EApp/node_modules"
8-
test:
9-
pre:
10-
- emulator -avd circleci-android22 -no-audio -no-window:
11-
background: true
12-
parallel: true
13-
- npm install -g react-native-cli
14-
- e2e/prepare.sh
15-
- circle-android wait-for-boot

js/googleApi.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,36 @@ function format(raw) {
2323
}
2424
}
2525

26-
for (let component of raw.address_components) {
27-
if (component.types.includes('route')) {
26+
raw.address_components.forEach(component => {
27+
if (component.types.indexOf('route') !== -1) {
2828
address.streetName = component.long_name;
2929
}
30-
else if (component.types.includes('street_number')) {
30+
else if (component.types.indexOf('street_number') !== -1) {
3131
address.streetNumber = component.long_name;
3232
}
33-
else if (component.types.includes('country')) {
33+
else if (component.types.indexOf('country') !== -1) {
3434
address.country = component.long_name;
3535
address.countryCode = component.short_name;
3636
}
37-
else if (component.types.includes('locality')) {
37+
else if (component.types.indexOf('locality') !== -1) {
3838
address.locality = component.long_name;
3939
}
40-
else if (component.types.includes('postal_code')) {
40+
else if (component.types.indexOf('postal_code') !== -1) {
4141
address.postalCode = component.long_name;
4242
}
43-
else if (component.types.includes('administrative_area_level_1')) {
43+
else if (component.types.indexOf('administrative_area_level_1') !== -1) {
4444
address.adminArea = component.long_name;
4545
}
46-
else if (component.types.includes('administrative_area_level_2')) {
46+
else if (component.types.indexOf('administrative_area_level_2') !== -1) {
4747
address.subAdminArea = component.long_name;
4848
}
49-
else if (component.types.includes('sublocality') || component.types.includes('sublocality_level_1')) {
49+
else if (component.types.indexOf('sublocality') !== -1 || component.types.indexOf('sublocality_level_1') !== -1) {
5050
address.subLocality = component.long_name;
5151
}
52-
else if (component.types.includes('point_of_interest') || component.types.includes('colloquial_area')) {
52+
else if (component.types.indexOf('point_of_interest') !== -1 || component.types.indexOf('colloquial_area') !== -1) {
5353
address.feature = component.long_name;
5454
}
55-
}
55+
});
5656

5757
return address;
5858
}

0 commit comments

Comments
 (0)