# react-native-geocoder-mrousavy

> react native geocoding and reverse geocoding - forked and modified by mrousavy

Latest version **0.6.2** (published 2020-08-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-geocoder-mrousavy
pnpm add react-native-geocoder-mrousavy
yarn add react-native-geocoder-mrousavy
bun add react-native-geocoder-mrousavy
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.2 |
| Published | 2020-08-15 |
| First published | 2020-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 27.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Marc Rousavy |
| Maintainers | mrousavy |
| Keywords | react-component, react-native, geocoding, ios, android |

## Links

- npm: https://www.npmjs.com/package/react-native-geocoder-mrousavy
- Repository: https://github.com/mrousavy/react-native-geocoder
- Issues: https://github.com/mrousavy/react-native-geocoder/issues
- npm.io page: https://npm.io/package/react-native-geocoder-mrousavy

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.6.2 (latest) — 2020-08-15
- 0.6.1 — 2020-08-15
- 0.6.0 — 2020-08-15

## README

# react-native-geocoder

> TODO: Merge https://github.com/devfd/react-native-geocoder/pull/87 ?
> TODO: Merge https://github.com/devfd/react-native-geocoder/pull/33 ?

[![CircleCI](https://circleci.com/gh/devfd/react-native-geocoder/tree/master.svg?style=shield)](https://circleci.com/gh/devfd/react-native-geocoder/tree/master)

geocoding services for react native

## Install

```sh
npm i react-native-geocoder-mrousavy
cd ios; pod install; cd ..
```

## Usage
```
import Geocoder from 'react-native-geocoder-mrousavy';

// Position Geocoding
var NY = {
  lat: 40.7809261,
  lng: -73.9637594
};

Geocoder.geocodePosition(NY).then(res => {
    // res is an Array of geocoding object (see below)
})
.catch(err => console.log(err))

// Address Geocoding
Geocoder.geocodeAddress('New York').then(res => {
    // res is an Array of geocoding object (see below)
})
.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 {

    const res = await Geocoder.geocodePosition(NY);
    ...

    const res = await Geocoder.geocodeAddress('London');
    ...
}
catch(err) {
    console.log(err);
}
```

## Geocoding object format
both iOS and Android will return the following object:

```js
{
    position: {lat, lng},
    formattedAddress: String, // the full address
    feature: String | null, // ex Yosemite Park, Eiffel Tower
    streetNumber: String | null,
    streetName: String | null,
    postalCode: String | null,
    locality: String | null, // city name
    country: String,
    countryCode: String
    adminArea: String | null
    subAdminArea: String | null,
    subLocality: String | null
}
```

## Notes

### iOS
iOS does not allow sending multiple geocoding requests simultaneously, hence if you send a second call, the first one will be cancelled.

### Android
geocoding may not work on older android devices (4.1) and will not work if Google play services are not available.

---
_Source: https://npm.io/package/react-native-geocoder-mrousavy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
