From 6b98b4978bc171ccab1c9e60d38f9d1013ca52bc Mon Sep 17 00:00:00 2001 From: Tolu Olowu Date: Sat, 18 Feb 2017 17:27:50 +0100 Subject: [PATCH] Fix few regressions, bump version: 1.0.8 --- README.md | 54 ++++++++++--------- .../rngoogleplaces/RNGooglePlacesModule.java | 14 ++--- index.js | 7 +-- package.json | 2 +- 4 files changed, 38 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index f1f1fc8..081dab2 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ iOS/Android Google Places Widgets (Autocomplete, Place Picker) and API Services ## Versioning: -- for RN >= 0.40.0, use v2+ (e.g. react-native-google-places@2.0.6) -- for RN (0.33.0 - 0.39.0), use v1+ or 0.8.8 (e.g. react-native-google-places@1.0.6) +- for RN >= 0.40.0, use v2+ (e.g. react-native-google-places@2.0.8) +- for RN (0.33.0 - 0.39.0), use v1+ or 0.8.8 (e.g. react-native-google-places@1.0.8) ## Install @@ -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. }) @@ -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); @@ -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. }) @@ -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); @@ -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. @@ -261,8 +262,8 @@ 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); @@ -270,12 +271,13 @@ To filter autocomplete results as listed for [Android](https://developers.google .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); diff --git a/android/src/main/java/com/arttitude360/reactnative/rngoogleplaces/RNGooglePlacesModule.java b/android/src/main/java/com/arttitude360/reactnative/rngoogleplaces/RNGooglePlacesModule.java index a7f9e71..63b4408 100644 --- a/android/src/main/java/com/arttitude360/reactnative/rngoogleplaces/RNGooglePlacesModule.java +++ b/android/src/main/java/com/arttitude360/reactnative/rngoogleplaces/RNGooglePlacesModule.java @@ -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)); @@ -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"); diff --git a/index.js b/index.js index 0d054c3..3e78961 100644 --- a/index.js +++ b/index.js @@ -28,7 +28,7 @@ class RNGooglePlaces { openPlacePickerModal(latLngBounds = {}) { return RNGooglePlacesNative.openPlacePickerModal({ - ...RNGooglePlaces.boundsDefaults, + ...RNGooglePlaces.boundsDefaults, ...latLngBounds }) } @@ -36,7 +36,8 @@ class RNGooglePlaces { getAutocompletePredictions(query, filterOptions = {}) { return RNGooglePlacesNative.getAutocompletePredictions(query, { ...RNGooglePlaces.filterDefaults, - ...filterOptions + ...RNGooglePlaces.boundsDefaults, + ...filterOptions }) } @@ -45,4 +46,4 @@ class RNGooglePlaces { } } -export default new RNGooglePlaces() +export default new RNGooglePlaces() \ No newline at end of file diff --git a/package.json b/package.json index 5fc48ea..2d866e3 100644 --- a/package.json +++ b/package.json @@ -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) ", - "version": "1.0.6", + "version": "1.0.8", "scripts": { }, "repository": {