-
Notifications
You must be signed in to change notification settings - Fork 290
/
index.js
54 lines (44 loc) · 1.25 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React from 'react'
import { NativeModules } from 'react-native'
const RNGooglePlacesNative = NativeModules.RNGooglePlaces
class RNGooglePlaces {
static optionsDefaults = {
type: '',
country: '',
useOverlay: false,
initialQuery: '',
useSessionToken: true,
locationBias: {
latitudeSW: 0,
longitudeSW: 0,
latitudeNE: 0,
longitudeNE: 0
},
locationRestriction: {
latitudeSW: 0,
longitudeSW: 0,
latitudeNE: 0,
longitudeNE: 0
}
}
static placeFieldsDefaults = []
openAutocompleteModal(options = {}, placeFields = []) {
return RNGooglePlacesNative.openAutocompleteModal({
...RNGooglePlaces.optionsDefaults,
...options
}, [...RNGooglePlaces.placeFieldsDefaults, ...placeFields])
}
getAutocompletePredictions(query, options = {}) {
return RNGooglePlacesNative.getAutocompletePredictions(query, {
...RNGooglePlaces.optionsDefaults,
...options
})
}
lookUpPlaceByID(placeID, placeFields = []) {
return RNGooglePlacesNative.lookUpPlaceByID(placeID, [...RNGooglePlaces.placeFieldsDefaults, ...placeFields])
}
getCurrentPlace(placeFields = []) {
return RNGooglePlacesNative.getCurrentPlace([...RNGooglePlaces.placeFieldsDefaults, ...placeFields])
}
}
export default new RNGooglePlaces()