在我的网站上:http://www.ilovefooddreams.com/eligibility我显示了一张谷歌地图,现在突然显示。
"Oops! Something went wrong.This page didn't load Google Maps correctly. See the JavaScript console for technical details."
我四处寻找,他们说要获取 API key 。我已经连接了一个,但它仍然无法正常工作。
这是代码
<html>
<head>
</head>
<body>
<div id="googleMap" style="width:1030px;height:380px;"></div>
</body>
<script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDV9O4nd02xCwyy-AeAmFJ_dR3SKh5GKAE&libraries=places&callback=initialize"
async defer>
</script>
<script>
var amsterdam=new google.maps.LatLng(34.0789742,-118.361875);
function initialize()
{
var mapProp = {
center:amsterdam,
zoom:13,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
var myCity = new google.maps.Circle({
center:amsterdam,
radius:3000,
strokeColor:"#0000FF",
strokeOpacity:0.8,
strokeWeight:2,
fillColor:"#0000FF",
fillOpacity:0.4
});
myCity.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</html>
我该如何解决这个问题?
谢谢!
您网站上当前的版本正在报告 Google Maps API 错误:MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error
在 javascript 控制台中。` 因为在包含 API 的页面上没有键(它与您在问题中发布的内容不同):
<script
src="https://maps.googleapis.com/maps/api/js">
</script>
我是一名优秀的程序员,十分优秀!