Skip to content

Commit

Permalink
Fix few regressions, bump version: 1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
tolu360 committed Feb 18, 2017
1 parent 0ac17fd commit 6b98b49
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 39 deletions.
54 changes: 28 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ iOS/Android Google Places Widgets (Autocomplete, Place Picker) and API Services
<img width=200 title="Place Picker Open - iOS" src="./shots/picker-ios.png">

## Versioning:
- for RN >= 0.40.0, use v2+ (e.g. [email protected].6)
- for RN (0.33.0 - 0.39.0), use v1+ or 0.8.8 (e.g. [email protected].6)
- for RN >= 0.40.0, use v2+ (e.g. [email protected].8)
- for RN (0.33.0 - 0.39.0), use v1+ or 0.8.8 (e.g. [email protected].8)

## Install

Expand Down Expand Up @@ -138,7 +138,7 @@ class GPlacesDemo extends Component {
openSearchModal() {
RNGooglePlaces.openAutocompleteModal()
.then((place) => {
console.log(place);
console.log(place);
// place represents user's selection from the
// suggestions and it is a simplified Google Place object.
})
Expand All @@ -165,11 +165,11 @@ To filter autocomplete results as listed for [Android](https://developers.google

```javascript
RNGooglePlaces.openAutocompleteModal({
type: 'establishment',
country: 'CA',
latitude: 53.544389,
longitude: -113.490927,
radius: 10
type: 'establishment',
country: 'CA',
latitude: 53.544389,
longitude: -113.490927,
radius: 10
})
.then((place) => {
console.log(place);
Expand All @@ -190,7 +190,7 @@ class GPlacesDemo extends Component {
openSearchModal() {
RNGooglePlaces.openPlacePickerModal()
.then((place) => {
console.log(place);
console.log(place);
// place represents user's selection from the
// suggestions and it is a simplified Google Place object.
})
Expand Down Expand Up @@ -218,11 +218,12 @@ To set the initial viewport that the place picker map should show when the picke
- **`radius`** _(Number)_ - Radius (in kilo-meters) from the center of the map view to the edge. Use this to set the default "zoom" of the map view when it is first opened. Only works if `latitude` and `longitude` are also given. Defaults to `0.1`.

If no initial viewport is set (no argument is passed to the `openPlacePickerModal()` method), the viewport will be centered on the device's location, with the zoom at city-block level.

```javascript
RNGooglePlaces.openPlacePickerModal({
latitude: 53.544389,
longitude: -113.490927,
radius: 0.01 // 10 meters
latitude: 53.544389,
longitude: -113.490927,
radius: 0.01 // 10 meters
})
.then((place) => {
console.log(place);
Expand All @@ -233,14 +234,14 @@ If no initial viewport is set (no argument is passed to the `openPlacePickerModa
#### Example Response from the Autocomplete & PlacePicker Modals
```javascript
{
placeID: "ChIJZa6ezJa8j4AR1p1nTSaRtuQ",
website: "https://www.facebook.com/",
phoneNumber: "+1 650-543-4800",
address: "1 Hacker Way, Menlo Park, CA 94025, USA",
name: "Facebook HQ",
types: [ 'street_address', 'geocode' ],
latitude: 37.4843428,
longitude: -122.14839939999999
placeID: "ChIJZa6ezJa8j4AR1p1nTSaRtuQ",
website: "https://www.facebook.com/",
phoneNumber: "+1 650-543-4800",
address: "1 Hacker Way, Menlo Park, CA 94025, USA",
name: "Facebook HQ",
types: [ 'street_address', 'geocode' ],
latitude: 37.4843428,
longitude: -122.14839939999999
}
```
- Note: The keys available from the response from the resolved `Promise` from calling `RNGooglePlaces.openAutocompleteModal()` are dependent on the selected place - as `phoneNumber, website` are not set on all `Google Place` objects.
Expand All @@ -261,21 +262,22 @@ To filter autocomplete results as listed for [Android](https://developers.google

```javascript
RNGooglePlaces.getAutocompletePredictions('Lagos', {
type: 'cities',
country: 'NG'
type: 'cities',
country: 'NG'
})
.then((place) => {
console.log(place);
})
.catch(error => console.log(error.message));
```
OR

```javascript
RNGooglePlaces.getAutocompletePredictions('pizza', {
type: 'establishments',
latitude: 53.544389,
longitude: -113.490927,
radius: 10
type: 'establishments',
latitude: 53.544389,
longitude: -113.490927,
radius: 10
})
.then((place) => {
console.log(place);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,11 @@ public void openPlacePickerModal(ReadableMap options, final Promise promise) {
double latitude = options.getDouble("latitude");
double longitude = options.getDouble("longitude");
double radius = options.getDouble("radius");
boolean useOverlay = options.getBoolean("useOverlay");
LatLng center = new LatLng(latitude, longitude);

try {
PlaceAutocomplete.IntentBuilder intentBuilder =
new PlaceAutocomplete.IntentBuilder(useOverlay ?
PlaceAutocomplete.MODE_OVERLAY :
PlaceAutocomplete.MODE_FULLSCREEN
);
PlacePicker.IntentBuilder intentBuilder =
new PlacePicker.IntentBuilder();

if (latitude != 0 && longitude != 0 && radius != 0) {
intentBuilder.setLatLngBounds(this.getLatLngBounds(center, radius));
Expand All @@ -254,11 +250,11 @@ public void openPlacePickerModal(ReadableMap options, final Promise promise) {
}

@ReactMethod
public void getAutocompletePredictions(String query, ReadableMap filter, final Promise promise) {
public void getAutocompletePredictions(String query, ReadableMap options, final Promise promise) {
this.pendingPromise = promise;

String type = filter.getString("type");
String country = filter.getString("country");
String type = options.getString("type");
String country = options.getString("country");
country = country.isEmpty() ? null : country;

double latitude = options.getDouble("latitude");
Expand Down
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ class RNGooglePlaces {

openPlacePickerModal(latLngBounds = {}) {
return RNGooglePlacesNative.openPlacePickerModal({
...RNGooglePlaces.boundsDefaults,
...RNGooglePlaces.boundsDefaults,
...latLngBounds
})
}

getAutocompletePredictions(query, filterOptions = {}) {
return RNGooglePlacesNative.getAutocompletePredictions(query, {
...RNGooglePlaces.filterDefaults,
...filterOptions
...RNGooglePlaces.boundsDefaults,
...filterOptions
})
}

Expand All @@ -45,4 +46,4 @@ class RNGooglePlaces {
}
}

export default new RNGooglePlaces()
export default new RNGooglePlaces()
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "iOS/Android Google Places Widgets (Autocomplete, Place Picker) and API Services for React Native Apps",
"main": "index.js",
"author": "Tolu Olowu (Arttitude 360) <[email protected]>",
"version": "1.0.6",
"version": "1.0.8",
"scripts": {
},
"repository": {
Expand Down

0 comments on commit 6b98b49

Please sign in to comment.