【问题标题】:Google API - Places autocomplete in React Native Expo ProjectGoogle API - 在 React Native Expo 项目中放置自动完成功能
【发布时间】:2021-03-25 09:15:26
【问题描述】:

我正在使用 React Native Expo 开发移动应用程序。我正在使用react-native-google-places-autocomplete 来自动完成位置/地点的文本。它是谷歌 API。我已经创建了帐户,启用了谷歌服务并添加了我的账单信息。但是代码不起作用。

请看下面的代码:

        <View style={{height: 500}}>
        <GooglePlacesAutocomplete

        fetchDetails={true}
        placeholder='Search'
        onPress={(data, details = null) => {
            console.log(data, details);
        }}
        query={{
            key: 'my-api-key-here',
            language: 'en',
        }}
        />
        </View>

我能够成功看到我可以输入的 Search 占位符,但我无法看到谷歌的建议/自动完成文本。我可以在框中成功输入位置,但谷歌没有提供位置建议。

我也安装并导入了相关库。

【问题讨论】:

  • 是滚动视图中的组件吗?
  • @StevenBell。你说的是哪个组件? GooglePlacesAutocompleteView 组件内。它在另一个 View 组件内部

标签: reactjs react-native google-api expo googleplacesautocomplete


【解决方案1】:

您需要添加道具 listViewDisplayed={boolean or "auto"}。看这个链接https://snack.expo.io/@tobzy/react-native-google-places-autocomplete-example

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-01
    • 2014-08-29
    • 1970-01-01
    • 2014-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多