From ab33243feeb82ba92c7ed1030b93e76aa9a23109 Mon Sep 17 00:00:00 2001 From: Fitim Date: Mon, 10 Sep 2018 11:59:13 +0200 Subject: [PATCH 1/2] enable google geocoder on ios --- index.d.ts | 5 +++++ js/geocoder.js | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..8cdba2d --- /dev/null +++ b/index.d.ts @@ -0,0 +1,5 @@ + +export interface Geocoder { + fallbackToGoogle: (apiKey: string) => void; + enableGoogleGeocoderIOS: () => void; +} diff --git a/js/geocoder.js b/js/geocoder.js index 3a4563e..7b7fe13 100644 --- a/js/geocoder.js +++ b/js/geocoder.js @@ -1,20 +1,32 @@ -import { NativeModules } from 'react-native'; +import { NativeModules, Platform } from 'react-native'; import GoogleApi from './googleApi.js'; const { RNGeocoder } = NativeModules; export default { apiKey: null, + useGoogleOnIOS: false, fallbackToGoogle(key) { this.apiKey = key; }, + enableGoogleGeocoderIOS() { + this.useGoogleOnIOS = Platform.OS === 'ios'; + }, + geocodePosition(position) { if (!position || !position.lat || !position.lng) { return Promise.reject(new Error("invalid position: {lat, lng} required")); } + if (this.useGoogleOnIOS) { + if (!this.apiKey) { + return Promise.reject(new Error("No api key")); + } + return GoogleApi.geocodePosition(this.apiKey, position); + } + return RNGeocoder.geocodePosition(position).catch(err => { if (!this.apiKey) { throw err; } return GoogleApi.geocodePosition(this.apiKey, position); @@ -26,6 +38,13 @@ export default { return Promise.reject(new Error("address is null")); } + if (this.useGoogleOnIOS) { + if (!this.apiKey) { + return Promise.reject(new Error("No api key")); + } + return GoogleApi.geocodeAddress(this.apiKey, position); + } + return RNGeocoder.geocodeAddress(address).catch(err => { if (!this.apiKey) { throw err; } return GoogleApi.geocodeAddress(this.apiKey, address); From 2ee513da1166ec54c7e13cbaeef1cf6bac075834 Mon Sep 17 00:00:00 2001 From: Fitim Date: Fri, 19 Jul 2019 10:31:23 +0200 Subject: [PATCH 2/2] update gradle build tool version --- android/build.gradle | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 8a174dc..2909971 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,14 +1,14 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 28 + buildToolsVersion "28.0.3" defaultConfig { minSdkVersion 16 - targetSdkVersion 25 - versionCode 1 - versionName "1.0" + targetSdkVersion 27 + versionCode 2 + versionName "1.1" ndk { abiFilters "armeabi-v7a", "x86" }