response-native-google-places-autocomplete не работает на React native 0.61

Я добавил response-native-google-places-autocomplete с пряжей в свой проект cli, поддерживающий реакцию, но он не работает. Вот проблемы, с которыми я столкнулся в настоящий момент.

  1. раскрывающийся список мест не отображается на IOS, однако текстовое поле ввода позволяет мне ввести название места, но список прогнозов не отображается

  2. Обработчик onPress вообще не запускается как на iOS, так и на android

  3. Текстовый ввод, поступающий из response-native-google-places-autocomplete, не позволяет мне вводить что-либо на ANDROID. Это похоже на то, что все время отключено (хотя фокус установлен на true)

Примечание: все api местоположения Google включены, api карт google, api мест и api геокода включены, и указан действительный ключ api.

Я перепробовал все возможные решения, включая следующие:

  1. установка zIndex: 1000 высокого значения, чтобы избежать его скрытия за каким-либо другим видом

  2. Пытался создать новое приложение RN и добавил только этот компонент, чтобы проект оставался чистым.

  3. Повторное создание API и даже использование другого API, который работает с предыдущими версиями REACT NATIVE.

Журналы ничего не показывают ни в Xcode, ни в Android Studio. Вот фрагмент кода:

        <View style = {[{zIndex: 2, backgroundColor: 'white'}]}>
                <GooglePlacesAutocomplete
                    ref = {ref => setSearchTextRef(ref)}
                    placeholder='Search for gym'
                    styles={{
                        container: {backgroundColor: 'transparent'},
                        textInputContainer: styles.viewStyle,
                        textInput: styles.textInputStyle,
                    }}
                    keyboardShouldPersistTaps = {'handled'}
                    listUnderlayColor = {'transparent'}
                    textInputProps = {{
                        onFocus: () => focusInput(),
                        onBlur: () => blurInput(),
                        onChangeText: (text) => onChange(text)
                    }}
                    minLength={1} // minimum length of text to search
                    returnKeyType={'search'}
                    listViewDisplayed={'auto'}   // true/false/undefined
                    fetchDetails={true}
                    renderDescription={row => row.description} // custom description render
                    onPress={(data, details = null) => {
                        let coordinates = details.geometry.location;
                        sendCoordinates(coordinates, {data, details});
                    }}
                    getDefaultValue={() => ''}
                    query={{
                        key: googleAPIKey,
                        language: 'en', // language of the results
                        // types: '(cities)' // default: 'geocode'
                    }}
                    nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
                    GooglePlacesSearchQuery={{
                        rankby: 'distance',
                        types: 'gym'
                    }}
                    filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} 
                    debounce={200}
                />
            </View>

заранее спасибо


person Ahmad Ali    schedule 12.02.2020    source источник


Ответы (2)


Ваш код с несколькими закомментированными вещами сработал для меня. Закомментировал ваши вызовы функций, поскольку они не были предоставлены.

      <View style = {[{zIndex: 2, backgroundColor: 'white'}]}>
          <GooglePlacesAutocomplete
              //ref = {ref => setSearchTextRef(ref)}
              placeholder='Search for gym'
              styles={{
                  container: {backgroundColor: 'transparent'},
                  //textInputContainer: styles.viewStyle,
                  //textInput: styles.textInputStyle,
              }}
              keyboardShouldPersistTaps = {'handled'}
              listUnderlayColor = {'transparent'}
              textInputProps = {{
                  //onFocus: () => focusInput(),
                  //onBlur: () => blurInput(),
                  //onChangeText: (text) => onChange(text)
              }}
              minLength={1} // minimum length of text to search
              returnKeyType={'search'}
              listViewDisplayed={'auto'}   // true/false/undefined
              fetchDetails={true}
              renderDescription={row => row.description} // custom description render
              onPress={(data, details = null) => {
                  let coordinates = details.geometry.location;
                  console.log(JSON.stringify(details)); //display details in console!
                  //sendCoordinates(coordinates, {data, details});
              }}
              getDefaultValue={() => ''}
              query={{
                key: 'YourKeyHere',
                language: 'en', // language of the results
                  // types: '(cities)' // default: 'geocode'
              }}
              nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
              GooglePlacesSearchQuery={{
                  rankby: 'distance',
                  types: 'gym'
              }}
              filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} 
              debounce={200}
          />
      </View>      
person Correal A    schedule 28.04.2020

Этот пакет больше не поддерживается и просто не работает. Пробовал на IOS с экспо. Я даже не получил списка результатов. Я нашел другой пакет, который отлично работает:

https://www.npmjs.com/package/react-native-places-input

person navvn    schedule 06.03.2020
comment
Вышеупомянутый пакет поддерживается. Релиз по ней был 10 дней назад. Удобно, что вы говорите, что он не поддерживается, когда отправляете свой собственный пакет. - person SKeney; 21.12.2020