我使用谷歌地图 API 为我的房间开发了一个带有自动完成地址的 Rails 应用程序。 问题是当我尝试在产品输入地址表单中输入时..有时我有地址建议..有时没有!当我收到建议后,点击它;它不会记录我在框中的点击。 在我的 Rails 控制台中,我检查了我的产品是否有纬度和经度:但没有记录任何内容。 在我的 Google 开发者控制台上,我激活了一个具有相同 ID 的 Google API: - Google map Javascript API key :有效;不记录事件 - Google Places 网络版 API key :有效;记录事件 我用费加罗来隐藏我的 key 。 经过几个小时的测试后我没能让它工作,这让我发疯了.. 有关信息,我在主页中的同一项目中使用了其他自动完成功能。而且效果非常好!
信息: 我的 js 控制台中出现以下错误: 您已超出此 API 的每日请求配额 我的主页的 js 控制台没有错误(它们使用相同的 API)
感谢帮助,这是我的代码:
我的脚本在我的布局中:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=<%= ENV['GOOGLE_API_KEY'] %>&libraries=places"></script>
<%= javascript_include_tag 'application' %>
<%= javascript_pack_tag 'application' %>
我的看法:
<div class="row">
<div class="col-md-3">
<%= render 'room_menu' %>
</div>
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading">
Location of the bottle
</div>
<div class="panel-body">
<div class="container">
<%= form_for @room do |f| %>
<div class="row">
<div class="form-group">
<label>Address of the bottle</label>
<%= f.text_field :address, placeholder: "Where is the bootle?", class: "form-control", required: true, id: "autoaddress" %>
</div>
</div>
<div class="text-center">
<%= f.submit "Save", class: "btn btn-form" %>
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>
<script>
$(function() {
$("#autoaddress").geocomplete();
})
</script>
最佳答案
错误的原因您已超出此 API 的每日请求配额
是因为您尚未为您的帐户设置结算信息
。
您必须为您的项目启用结算帐户。为此,您可以引用this
关于javascript - [ rails ] : Google Map autocomplete not recording input,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51908427/