Я использую https://github.com/FaridSafi/react-native-google-places-autocomplete/blob/master/GooglePlacesAutocompleteExample/Example.js, чтобы помочь пользователям найти свой адрес для доставки.
Я использую API-ключ браузера от Google Места. Я использую iOS-устройство и симулятор. Однако я просто вижу необработанное обещание каждый раз, когда печатаю. (см. рис. ниже). Я также включил безопасность транспорта приложений, чтобы разрешить произвольные загрузки. Я не получаю предложений вообще. Я проверил свои ключи в браузере с помощью URL-адреса, и он работает, поэтому я знаю, что моя учетная запись активирована и работает. Я также не вижу ошибок в облачной консоли.
<GooglePlacesAutocomplete
placeholder='Search'
minLength={2}
autoFocus={false}
returnKeyType={'search'}
keyboardAppearance={'light'}
listViewDisplayed={false}
fetchDetails={true}
keyboardShouldPersistTaps="handled"
renderDescription={row => row.description}
onPress={(data, details = null) => {
console.log(data, details);
this.setState({ location: data.structured_formatting.main_text, user_long: details.geometry.location.lng, user_lat: details.geometry.location.lat })
}}
enablePoweredByContainer={false}
getDefaultValue={() => ''}
textInputProps={{
ref: (input) => { this.fourthTextInput = input }
}}
query={{
// available options: https://developers.google.com/places/web-service/autocomplete
key: 'MY_API_KEY',
language: 'en',
region: "US", //It removes the country name from the suggestion list
// types: '', // default: 'geocode'
components: 'country:us'
}}
styles={{
container: { width: 300 },
textInputContainer: {
backgroundColor: 'transparent',
margin: 0,
width: 200,
padding: 0,
borderTopWidth: 0,
borderBottomWidth: 0
},
textInput: {
textAlign: 'center',
minWidth: 40,
borderColor: "#cbb4c0",
borderBottomWidth: 1,
color: '#5d5d5d',
fontSize: 14,
},
description: {
color: '#ac879a',
fontWeight: '300'
},
predefinedPlacesDescription: {
color: '#1faadb'
}
}}
currentLocation={false}
nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
GoogleReverseGeocodingQuery={{// available options for GoogleReverseGeocoding API : https://developers.google.com/maps/documentation/geocoding/intro
}}
GooglePlacesSearchQuery={{
// available options for GooglePlacesSearch API : https://developers.google.com/places/web-service/search
rankby: 'distance',
type: 'cafe'
}}
GooglePlacesDetailsQuery={{
// available options for GooglePlacesDetails API : https://developers.google.com/places/web-service/details
fields: 'formatted_address',
}}
filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']}
debounce={200}
/>
