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

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
switch to es5 (not all es6 features are supported on RN)
  • Loading branch information
devfd committed May 20, 2016
1 parent a383e62 commit ca401f2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ Geocoder.geocodeAddress('New York').then(res => {
.catch(err => console.log(err))
```

## Fallback to google maps geocoding

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)

```js
import Geocoder from 'react-native-geocoder';
// simply add your google key
Geocoder.fallbackToGoogle(MY_KEY);

// use the lib as usual
let ret = await Geocoder.geocodePosition({lat, lng})
// you get the same results

```

## With async / await
```
try {
Expand Down
12 changes: 0 additions & 12 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
machine:
node:
version: 5.11.1
dependencies:
cache_directories:
- "node_modules"
- "e2e/GeocoderE2EApp/node_modules"
test:
pre:
- emulator -avd circleci-android22 -no-audio -no-window:
background: true
parallel: true
- npm install -g react-native-cli
- e2e/prepare.sh
- circle-android wait-for-boot
22 changes: 11 additions & 11 deletions js/googleApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,36 @@ function format(raw) {
}
}

for (let component of raw.address_components) {
if (component.types.includes('route')) {
raw.address_components.forEach(component => {
if (component.types.indexOf('route') !== -1) {
address.streetName = component.long_name;
}
else if (component.types.includes('street_number')) {
else if (component.types.indexOf('street_number') !== -1) {
address.streetNumber = component.long_name;
}
else if (component.types.includes('country')) {
else if (component.types.indexOf('country') !== -1) {
address.country = component.long_name;
address.countryCode = component.short_name;
}
else if (component.types.includes('locality')) {
else if (component.types.indexOf('locality') !== -1) {
address.locality = component.long_name;
}
else if (component.types.includes('postal_code')) {
else if (component.types.indexOf('postal_code') !== -1) {
address.postalCode = component.long_name;
}
else if (component.types.includes('administrative_area_level_1')) {
else if (component.types.indexOf('administrative_area_level_1') !== -1) {
address.adminArea = component.long_name;
}
else if (component.types.includes('administrative_area_level_2')) {
else if (component.types.indexOf('administrative_area_level_2') !== -1) {
address.subAdminArea = component.long_name;
}
else if (component.types.includes('sublocality') || component.types.includes('sublocality_level_1')) {
else if (component.types.indexOf('sublocality') !== -1 || component.types.indexOf('sublocality_level_1') !== -1) {
address.subLocality = component.long_name;
}
else if (component.types.includes('point_of_interest') || component.types.includes('colloquial_area')) {
else if (component.types.indexOf('point_of_interest') !== -1 || component.types.indexOf('colloquial_area') !== -1) {
address.feature = component.long_name;
}
}
});

return address;
}
Expand Down

0 comments on commit ca401f2

Please sign in to comment.