react-native-google-places-autocomplete不适用于React native 0.61

问题描述 投票:0回答:1

我已在我的react-native cli项目中添加了带有yarn的react-native-google-places-autocomplete,但是它不起作用。这是我目前面临的问题。

  1. 位置下拉列表未在IOS上显示,但是输入文本字段允许我输入位置名称,但没有出现预测列表

  2. onPress处理程序在IOS和android上均未触发。

  3. 来自react-native-google-places-autocomplete的文本输入不允许我在ANDROID上输入任何内容。就像一直禁用(尽管将焦点设置为true一样)

  4. 注意:已启用所有google location api,已启用google maps api,places api和geocode api并给出了有效的api密钥。

    我尝试了所有可能的解决方案,包括以下内容:

  1. 设置zIndex:1000的高值,以避免将其隐藏在其他视图后面

  2. 尝试创建新的RN App并仅添加了此组件以保持项目干净

  3. 重新生成API,甚至使用与以前版本的REACT NATIVE一起使用的其他API。
  4. 日志在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>
    
    

提前谢谢您

我已在我的react-native cli项目中添加了带有yarn的react-native-google-places-autocomplete,但是它不起作用。这是我目前面临的问题。下拉列表中没有显示...

android ios react-native google-places-api googleplacesautocomplete
1个回答
0
投票

此软件包已不再维护,根本无法正常工作。我尝试在Expo上使用IOS。我什至没有得到结果清单。我找到了另一个像咒符一样工作的包:

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

© www.soinside.com 2019 - 2024. All rights reserved.