简体   繁体   English

Google API - 在 React Native Expo 项目中放置自动完成功能

[英]Google API - Places autocomplete in React Native Expo Project

I am developing mobile app using React Native Expo .我正在使用 React Native Expo开发移动应用程序。 I am using react-native-google-places-autocomplete for text auto completetion of location/places.我正在使用react-native-google-places-autocomplete来自动完成位置/地点的文本。 It is Google API.它是谷歌 API。 I have made account, enabled the google service and also added my billing info.我已经创建了帐户,启用了谷歌服务并添加了我的账单信息。 But the code is not working.但是代码不起作用。

See the code below:请看下面的代码:

        <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>

I am able to SUCCESSFULLY see the Search placeholder where I can type, but I am not able to see the suggestions/autocompletion text by google.我能够成功地看到我可以输入的Search占位符,但我无法看到谷歌的建议/自动完成文本。 I am able to type the location successfully in the box, but there is no location suggestions coming by google.我可以在框中成功输入位置,但谷歌没有提供位置建议。

I have installed and imported relevant libraries too.我也安装并导入了相关库。

You need to add prop listViewDisplayed={boolean or "auto"}.您需要添加道具 listViewDisplayed={boolean or "auto"}。 See this link https://snack.expo.io/@tobzy/react-native-google-places-autocomplete-example请参阅此链接https://snack.expo.io/@tobzy/react-native-google-places-autocomplete-example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 谷歌自动完成将 api 放入反应中 - google autocomplete places api in react 如何在 React 项目中加载 Google Places JS API 库? - How to load the Google Places JS API Library in a React Project? 为什么这个搜索输入不可点击? 使用 react-native-google-places-autocomplete - Why is this search input not clickable? Using react-native-google-places-autocomplete 如何在 React Native 中更改 Google Places 自动完成组件上的占位符文本? - How Do I Change Placeholder Text on Google Places Autocomplete Component in React Native? React-native-google-places-autocomplete:将动态字符串变量传递给查询 - React-native-google-places-autocomplete: passing dynamic string variables to a query react-native-google-places-autocomplete 给它一个值,而不仅仅是默认(初始)值 - react-native-google-places-autocomplete give it a value rather than just default (initial) value Google 在 React 组件中放置了自动完成功能 - Google places autocomplete inside a react component Google Places API 自动完成不显示结果 - Google Places API Autocomplete Not Showing Results 回应:Google Places API /地方详情 - React: Google Places API/ Places Details google react-places-autocomplete api 将搜索建议限制在澳大利亚/单个国家/地区 - google react-places-autocomplete api restrict search suggestions to Australia / single country
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM