Skip to content

Commit cbfe121

Browse files
committed
chore: update readme
1 parent 55e2eec commit cbfe121

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

README.md

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
Multi-platform Geocoding library for React Native apps.
44

5-
65
[![CircleCI](https://circleci.com/gh/timwangdev/react-native-geocoder-reborn/tree/master.svg?style=shield)](https://circleci.com/gh/timwangdev/react-native-geocoder-reborn/tree/master)
76
[![npm](https://img.shields.io/npm/v/@timwangdev/react-native-geocoder.svg)](https://www.npmjs.com/package/@timwangdev/react-native-geocoder)
87
[![Downloads](https://img.shields.io/npm/dw/@timwangdev/react-native-geocoder.svg)](https://www.npmjs.com/package/@timwangdev/react-native-geocoder)
98

10-
The project is originally forked from [devfd/react-native-geocoder](https://github.com/devfd/react-native-geocoder). Since 1.0 the project have been refactored and supports more features includes maximum results limit, search boundary and React hooks.
9+
The project is originally forked from [devfd/react-native-geocoder](https://github.com/devfd/react-native-geocoder). Since 1.0 the project have been refactored and supports more features includes web support, maximum results limit, search boundary and request headers for Google Maps API.
1110

12-
**Please check the [Release page](https://github.com/timwangdev/react-native-geocoder-reborn/releases/tag/v1.0.0) for Version 1.0.0 Full Changelog and Migration Guide.**
11+
**Please check the [GitHub Release page](https://github.com/timwangdev/react-native-geocoder-reborn/releases/) for Version 1.0.0 Full Changelog and Migration Guide.**
1312

1413
## Installation
1514

@@ -113,66 +112,74 @@ try {
113112

114113
### Geocode Address
115114

116-
* `Geocoder.geocodeAddress(address: string, options?: GeocoderOptions)`
115+
* __`Geocoder.geocodeAddress(address: string, options?: GeocoderOptions)`__
117116

118-
* Returns `Promise<GeocodingObject[]>`
117+
* Returns `Promise<GeocodingObject[]>`
119118

120-
* Supports `regionIos` on iOS.
119+
* Supports `regionIos` on iOS for preferred search boundary.
121120

122-
* Supports `bounds` on Android and Google Maps API.
121+
* Supports `bounds` on Android and Google Maps API.
123122

124123
### Geocode Position (Reverse Geocoding)
125124

126-
* `Geocoder.geocodePosition(position: { lat: number, lng: number }, options?: GeocoderOptions)`
125+
* __`Geocoder.geocodePosition(position: { lat: number, lng: number }, options?: GeocoderOptions)`__
127126

128-
* Returns `Promise<GeocodingObject[]>`
127+
* Returns `Promise<GeocodingObject[]>`
129128

130129
### `GeocoderOptions`
131130

132131
```typescript
133132
{
134-
// Your Google Maps API key, required if when `fallbackToGoogle` or `forceGoogleOnIos` is set. Make sure Geocoding API is enabled.
133+
// Your Google Maps API key, required if `fallbackToGoogle` or `forceGoogleOnIos` is `true`.
135134
apiKey?: string;
136135

137136
// Preferred Locale for outputs, defaults to 'en'. (See Note 1)
138137
locale?: string;
139138

140-
// (Not available for Google Maps) Maximum returned results, defaults to 5
139+
// Max number of addresses to return, defaults to 2. (See Note 2)
141140
maxResults?: number;
142141

143-
// (Android and Google only) Set the bounds for address geocoding. (See Note 2)
142+
// (Android and Google only) Set the bounds for address geocoding. (See Note 3)
144143
bounds?: {
145-
sw: { lat: number, lng: number }, // Lower left corner
146-
ne: { lat: number, lng: number }, // Upper right corner
144+
// Lower left corner
145+
sw: { lat: number, lng: number },
146+
147+
// Upper right corner
148+
ne: { lat: number, lng: number },
147149
};
148150

149-
// (iOS native only) Set circular region for address geocoding. (See Note 2)
151+
// (iOS native only) Set circular region for address geocoding. (See Note 3)
150152
regionIos?: {
151-
center: { lat: number, lng: number }, // Center of the circular region
152-
radius: number, // Radius of the circular region. Unit: km
153+
// Center of the circular region
154+
center: { lat: number, lng: number },
155+
156+
// Radius of the circular region. Unit: km
157+
radius: number,
153158
};;
154159

155160
// Should use Google Maps API if native query fails, defaults to false.
156161
fallbackToGoogle?: boolean;
157162

158-
// Should always use Google Maps API on iOS, defaults to false. (See Note 3)
163+
// Should always use Google Maps API on iOS, defaults to false. (See Note 4)
159164
forceGoogleOnIos?: boolean;
160165

161-
// Custom headers when sending Google Maps API requests. (See Note 4)
166+
// Custom headers when sending Google Maps API requests. (See Note 5)
162167
requestHeaders?: { [key: string]: string };
163168
}
164169
```
165170
#### Notes:
166171

167172
1. Platforms may have different implantations for locale preference. Here is [Google Maps API supported language list](https://developers.google.com/maps/faq#languagesupport).
168173

174+
2. Generally, only one entry will return, though the geocoder may return several results when address queries are ambiguous. Smaller numbers (1 to 5) for `maxResults` are recommended.
175+
169176
2. On iOS the preferred search boundary for address geocoding only support "circular" region, while on Android and Google Maps API it using "rectangular" bounds. `regionIos` will have no effect if `forceGoogleOnIos` is `true`.
170177

171178
3. Use `forceGoogleOnIos` if you want consistent result on both iOS and Android platform, due to the limitation of iOS native implantation.
172179

173180
4. `requestHeaders` is useful together with Google API credentials restrictions by setting the `Referer` header. See [#20](https://github.com/timwangdev/react-native-geocoder-reborn/issues/20).
174181

175-
5. In order to avoid hitting rate limit or reducing API queries, you could cache the results in your program whenever possible.
182+
5. In order to avoid hitting rate limit or reducing API queries, you should cache the results in your program whenever possible.
176183

177184
### `GeocodingObject`
178185

src/geocoder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let defaultOptions = {
77
locale: 'en',
88
fallbackToGoogle: false,
99
forceGoogleOnIos: false,
10-
maxResults: 5,
10+
maxResults: 2,
1111
};
1212

1313
function getApiKey(apiKey?: string) {

0 commit comments

Comments
 (0)