Google Places Autocomplete API 键在实时表单和闪亮上不起作用(但在 jsfiddle 上有效)
Google Places Autocomplete API key not working on live form & shiny (but works on jsfiddle)
我正在尝试通过 google 脚本创建一个 html 表单,并且有一个需要自动完成的位置字段 api。我使用闪亮的应用程序尝试了同样的操作,但我遇到了类似的错误。
代码在 jsfiddle 中尝试时有效,但在 运行 通过实时 google 脚本 url/ shiny app 时相同,导致错误。 “糟糕,出了点问题”。
在控制台上检查时的错误是:
“Google 地图 JavaScript API 错误:RefererNotAllowedMapError”
但是我没有对 api 键设置任何限制(让它至少工作一次)。
API Key Config Settings
我还在项目中启用了计费功能。 (但显然仍然计划 运行 我有免费学分的项目 :D)
我已经按照本教程中所示的代码格式来构建表单。 https://www.bpwebs.com/how-to-create-data-entry-form-with-google-html-service-and-submit-data-to-google-sheets/ 并自定义表格以适合我的领域。
关于如何尝试使其在 google 脚本 url 或 shiny 上工作有什么建议吗?
很遗憾,基本用户无法获得 google 云支持,因此需要社区提供帮助。
示例代码:
<!-- source: https://github.com/jamiewilson/form-to-google-sheets-->
<script src="https://maps.googleapis.com/maps/api/js?key=EnterKEY&libraries=places&callback=initMap"></script>
<form name="tutorial-check">
<div class="form-row">
<label for="locationTextField">Select Eatery:</label>
<input id="locationTextField" type="text" size="50" name = "eateryname">
<script>
function init() {
var input = document.getElementById('locationTextField');
var autocomplete = new google.maps.places.Autocomplete(input);
}
google.maps.event.addDomListener(window, 'load', init);
</script>
</div>
<br>
<label for="rating">Choose Rating: </label>
<div class="form-row" col-md-6>
<input type='radio' name='rating' value='0'> 0:
<input type='radio' name='rating' value='1'> 1:
<input type='radio' name='rating' value='2'> 2:
<input type='radio' name='rating' value='3'> 3:
<input type='radio' name='rating' value='4'> 4:
<input type='radio' name='rating' value='5'> 5:
<br>
</div>
<div class="form-row">
<button type="submit">Send</button>
</div>
</form>
非常感谢。
经过数周围绕 api 问题的斗争,我终于找到了问题所在并得以解决。将其发布给可能因类似问题而面临问题的其他所有人。
显然 Google 印度的地图平台有不同的规则。 google 云计费帐户不能用于 Google Maps Platform 使用。而且它不会在控制台上出错,我们知道 api 无法使用的问题是因为缺少用于地图 api 的额外计费帐户.
https://developers.google.com/maps/gmp-india-faq
所以需要做的是,如果您的项目像我的一样只包含地图 api,那么您可以从项目中禁用现有的结算帐户,为地图项目设置一个新帐户,然后 link 它与项目有关。
这应该可以解决“Google 地图 JavaScript API 错误:RefererNotAllowedMapError”的错误。
也许其他国家的情况并非如此,但无论这些新规则集在哪里,这都是需要注意的新问题。
我正在尝试通过 google 脚本创建一个 html 表单,并且有一个需要自动完成的位置字段 api。我使用闪亮的应用程序尝试了同样的操作,但我遇到了类似的错误。
代码在 jsfiddle 中尝试时有效,但在 运行 通过实时 google 脚本 url/ shiny app 时相同,导致错误。 “糟糕,出了点问题”。
在控制台上检查时的错误是: “Google 地图 JavaScript API 错误:RefererNotAllowedMapError”
但是我没有对 api 键设置任何限制(让它至少工作一次)。
API Key Config Settings
我还在项目中启用了计费功能。 (但显然仍然计划 运行 我有免费学分的项目 :D)
我已经按照本教程中所示的代码格式来构建表单。 https://www.bpwebs.com/how-to-create-data-entry-form-with-google-html-service-and-submit-data-to-google-sheets/ 并自定义表格以适合我的领域。
关于如何尝试使其在 google 脚本 url 或 shiny 上工作有什么建议吗?
很遗憾,基本用户无法获得 google 云支持,因此需要社区提供帮助。
示例代码:
<!-- source: https://github.com/jamiewilson/form-to-google-sheets-->
<script src="https://maps.googleapis.com/maps/api/js?key=EnterKEY&libraries=places&callback=initMap"></script>
<form name="tutorial-check">
<div class="form-row">
<label for="locationTextField">Select Eatery:</label>
<input id="locationTextField" type="text" size="50" name = "eateryname">
<script>
function init() {
var input = document.getElementById('locationTextField');
var autocomplete = new google.maps.places.Autocomplete(input);
}
google.maps.event.addDomListener(window, 'load', init);
</script>
</div>
<br>
<label for="rating">Choose Rating: </label>
<div class="form-row" col-md-6>
<input type='radio' name='rating' value='0'> 0:
<input type='radio' name='rating' value='1'> 1:
<input type='radio' name='rating' value='2'> 2:
<input type='radio' name='rating' value='3'> 3:
<input type='radio' name='rating' value='4'> 4:
<input type='radio' name='rating' value='5'> 5:
<br>
</div>
<div class="form-row">
<button type="submit">Send</button>
</div>
</form>
非常感谢。
经过数周围绕 api 问题的斗争,我终于找到了问题所在并得以解决。将其发布给可能因类似问题而面临问题的其他所有人。
显然 Google 印度的地图平台有不同的规则。 google 云计费帐户不能用于 Google Maps Platform 使用。而且它不会在控制台上出错,我们知道 api 无法使用的问题是因为缺少用于地图 api 的额外计费帐户.
https://developers.google.com/maps/gmp-india-faq
所以需要做的是,如果您的项目像我的一样只包含地图 api,那么您可以从项目中禁用现有的结算帐户,为地图项目设置一个新帐户,然后 link 它与项目有关。
这应该可以解决“Google 地图 JavaScript API 错误:RefererNotAllowedMapError”的错误。
也许其他国家的情况并非如此,但无论这些新规则集在哪里,这都是需要注意的新问题。