我的Google Map JavaScript API不再起作用。看来Google阻止了我。看this link。在控制台中,我得到以下错误:
Google Maps JavaScript API error: RefererDeniedMapError
https://developers.google.com/maps/documentation/javascript/error-messages#referer-denied-map-error
_.Ic @ js?key=AIzaSyDyECNnY4HOjiGu7m0f43yvlNe7Y9AgRcs&callback=initMap:53
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<style>
/* Set the size of the div element that contains the map */
#map {
height: 400px; /* The height is 400 pixels */
width: 100%; /* The width is the width of the web page */
}
</style>
</head>
<body>
<h3>My Google Maps Demo</h3>
<!--The div element for the map -->
<div id="map"></div>
<script>
// Initialize and add the map
function initMap() {
// The location of Uluru
var uluru = {lat: -25.344, lng: 131.036};
// The map, centered at Uluru
var map = new google.maps.Map(
document.getElementById('map'), {zoom: 4, center: uluru});
// The marker, positioned at Uluru
var marker = new google.maps.Marker({position: uluru, map: map});
}
</script>
<!--Load the API from the specified URL
* The async attribute allows the browser to render the page while the API loads
* The key parameter will contain your own API key (which is not needed for this tutorial)
* The callback parameter executes the initMap() function
-->
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDyECNnY4HOjiGu7m0f43yvlNe7Y9AgRcs&callback=initMap">
</script>
</body>
</html>
我该如何解决?!
答案 0 :(得分:2)
只需打开错误消息中提到的文档链接并阅读其内容
https://developers.google.com/maps/documentation/javascript/error-messages#referer-denied-map-error
在收到几封电子邮件通知后,您的应用因未遵守Google Maps Platform服务条款而被阻止。要对该块提出上诉并审核您的实施,请填写此表格。您将在几个工作日内通过电子邮件收到回复。
因此,解除锁定您的网站的唯一选择是按照文档中的说明向Google提交网络表单。
我希望这会有所帮助!