【问题标题】:How to use Google Places Autocomplete API in React Native Android?如何在 React Native Android 中使用 Google Places Autocomplete API?
【发布时间】:2015-10-14 06:01:06
【问题描述】:

我正在尝试在 RN Android 中使用 Google Places Autocomplete API(链接到 Google Doc,如下所示)。但是,由于 API 的 JS 版本是为网络应用程序设计的,我不确定如何将脚本包含到我的 RN Android 代码中(网络应用程序的原始代码:)。有没有办法在 RN 中使用这个 API?还是因为 Google Places API 也有 Android 原生版本,所以我们是否必须按照 RN 官方文档中的“Guides(Android)/Native Modules”中的说明,编写一个 Android 原生模块并将其与 RN 挂钩?

非常感谢!

Google Places 自动完成 API JS:https://developers.google.com/maps/documentation/javascript/places-autocomplete

关于原生模块的官方 RN 文档:http://facebook.github.io/react-native/docs/native-modules-android.html#content

【问题讨论】:

标签: google-places-api react-native


【解决方案1】:

尽量避免使用https://github.com/FaridSafi/react-native-google-places-autocomplete,因为这将使用不支持移动应用程序 API 密钥限制的 Google Places API。

【讨论】:

【解决方案2】:

您可以使用npm install googleplaces 在您的项目中安装 google Places npm 包并 在您的代码中使用require('googleplaces') 来访问它

结帐https://www.npmjs.com/package/googleplaces 了解更多详情。我还没有测试过,但我想你可以像其他 npm 包一样使用它来进行 react-native

【讨论】:

  • 非常感谢!我会自己测试一下。
  • @ZJL 嘿,你测试过吗。我被困在与 airbnb 的 react-native 地图一起实现这一点
  • @KiranMathewMohan 我后来使用了模块 FaridSafi/react-native-google-places-autocomplete 来实现这个功能
猜你喜欢
  • 1970-01-01
  • 2020-05-27
  • 1970-01-01
  • 2019-09-18
  • 1970-01-01
  • 2018-06-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-27
相关资源
最近更新 更多