在我的网站上:http://www.ilovefooddreams.com/eligibility这些地图工作得很好,但现在突然间说:
**
**
有谁知道出了什么问题?这是我的代码:
{% extends "base.html" %}
{% block header_class %}header-expanded slidepanel top
{% endblock %}
{% block header_content %}
{{ super() }}
<div style="image-align:left;">
<h2 class="heading h-section" data-barley="index_heading"style="color:black" data-barley-editor="simple">You are eligible for delivery at any address within this circle.</h2>
</div>
<!DOCTYPE html>
<html>
<head>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDV9O4nd02xCwyy-AeAmFJ_dR3SKh5GKAE&callback=initMap">
</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>
</head>
<body>
<div id="googleMap" style="width:1030px;height:380px;"></div>
</body>
</html>
{% endblock %}
感谢您的帮助!
答案 0 :(得分:2)
您似乎没有API密钥。
就在你的代码中:
<script src="https://maps.googleapis.com/maps/api/js"></script>
缺少一些东西。它应该是这样的:
<script src="https://maps.googleapis.com/maps/api/js?key=**YOUR_API_KEY**&callback=initMap"></script>
您将在获取API密钥之后的本文档中获取API密钥 https://developers.google.com/maps/documentation/javascript/get-api-key?hl=de
或 https://developers.google.com/maps/documentation/javascript/get-api-key?hl=en(英文)
然后在上面的链接和你的全部设置中添加它!
答案 1 :(得分:1)