首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将Google API添加到meteor项目

将Google API添加到meteor项目
EN

Stack Overflow用户
提问于 2012-10-29 22:44:48
回答 3查看 4.2K关注 0票数 2

我试图将Google API链接到我的meteor项目,但似乎无法使其加载。医生说要添加

代码语言:javascript
运行
复制
script src="https://apis.google.com/js/client.js?onload=OnLoadCallback"></script>

到头部,我们不能直接在流星上做。

我尝试获取脚本的本地副本并将其添加到客户端文件夹,但在加载时仍然得到'gapi is not defined‘。这种方法适用于filepicker.io,但不适用于这一种。

你知道在哪里或者如何加载这个库吗?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-01-27 08:38:12

发现:最好的方法是使用Google RESTful api。你可以在This SO Question上看到一个可用的例子

票数 2
EN

Stack Overflow用户

发布于 2012-10-30 03:50:41

你可以使用Meteor内置的外部服务来进行身份验证,他们有一个专门针对谷歌的服务:http://docs.meteor.com/#meteor_loginwithexternalservice

要加载client API,只需将其包含在应用程序主html文件的<head>部分。

代码语言:javascript
运行
复制
<script src="https://apis.google.com/js/client.js?onload=OnLoadCallback"></script>

您可以通过在控制台中运行gapi来确认它是否已正确加载

票数 2
EN

Stack Overflow用户

发布于 2021-12-17 11:56:29

代码语言:javascript
运行
复制
// Create the script tag, set the appropriate attributes
var script = document.createElement('script');
script.src = 'https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap';
script.async = true;

// Attach your callback function to the `window` object
window.initMap = function() {
  // JS API is loaded and available
};

// Append the 'script' element to 'head'
document.head.appendChild(script);

参见reference

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13123881

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档