reactjs - _reactNativeGeocoding.default.setApiKey 不是函数
问题描述
我试图在 React Native 中获取给定地址的坐标。我尝试了以下方法:
import Geocoder from 'react-native-geocoding';
Geocoder.setApiKey("AIz...ZI");
Geocoder.from("London Eye")
.then(json => {
var location = json.results[0].geometry.location;
console.log(location);
})
.catch(error => console.warn(error));
我把“...”放在 API 中只是为了隐藏整个密钥。
当我调用此代码所在的方法时,出现错误:
_reactNativeGeocoding.default.setApiKey is not a function
解决方案
要设置 api 密钥,您需要调用“init”方法而不是 setApiKey
Geocoder.init('AIz...ZI');
推荐阅读
- web-services - ASMX WebService 没有从 xmlns:ns1 子命名空间获取请求值(xmlns:ns1 问题)
- c++ - 带数组的广播函数
- indexing - 最小值和最大值的八度代码以及查找索引
- c# - C# Winforms 应用程序中总进程内存使用情况的矛盾报告
- flutter - 修改默认的 ExpansionTile 子项垂直填充 Flutter
- mysql - 转移开始在我的 ASP.NET API 上花费的时间太长
- https - 为 macOS [mac os catalina 10.15.2] 在 localhost 上设置 HTTPS
- javascript - 如何设置 WordPress 和 WooCommerce API,以便在发布时不会出现 CORS 错误?
- autodesk-forge - 使用 Auto-desk Forge 实现登录系统
- python - 使用 pymongo 将数据插入 mongo 时删除 NaT 值