[英]Adding google maps Api to a project build with Bower & Grunt
I'm working with the Yeoman webapp generator ( https://github.com/yeoman/generator-webapp ) and I've added the Bower package GMAPS ( https://github.com/hpneo/gmaps ). 我正在使用Yeoman Webapp生成器( https://github.com/yeoman/generator-webapp ),并且添加了Bower软件包GMAPS( https://github.com/hpneo/gmaps )。 After adding Gmaps to my project I add the Google Api link in the top of my project like this
将Gmaps添加到我的项目后,我在项目顶部添加Google Api链接,如下所示
<!-- build:css(.tmp) styles/main.css -->
<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
Problem is, when I use the Grunt Serve
command that I see my Gmaps appearing on my website that runs on my localhost. 问题是,当我使用
Grunt Serve
命令时,我看到我的Gmaps出现在我的本地主机上运行的网站上。 If I Grunt
and build my project it always gives me an error that in my main.js
file it cannot find the variable Gmaps (that is used to trigger the Gmaps-plugin). 如果我
Grunt
并构建我的项目,它总是会给我一个错误,即在我的main.js
文件中找不到变量Gmaps(用于触发Gmaps插件)。
So my question: How do I add API's to a project that is build with Grunt? 所以我的问题是:如何将API添加到使用Grunt构建的项目中?
You need to copy google api link outsite the generators tags in the index.html. 您需要将Google api链接复制到index.html中的generators标签之外。 For example:
例如:
<script src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>
<!-- build:js(.) scripts/vendor.js -->
</script>
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
</script>
<!-- endbower -->
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.