糟了!出了点问题。此页面未正确加载Google地图。有关技术详细信息,请参阅JavaScript控制台。
我也不知道原因
API error: RefererNotAllowedMapError
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=myAPI&callback=initMap"
async defer></script>
</body>
</html>
发布于 2016-09-05 15:53:27
请看谷歌地图应用编程接口教程:https://developers.google.com/maps/documentation/javascript/tutorials/adding-a-google-map
仔细阅读时,您会发现需要一个密钥YOUR_API_KEY
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
</script>要获取钥匙,请转到此处:https://developers.google.com/maps/documentation/javascript/tutorials/adding-a-google-map#key
发布于 2016-07-11 15:44:30
我在尝试使用Google Maps API时也遇到了同样的问题。收到相同的消息,请查看JavaScript控制台。真是浪费时间!
在我的例子中,问题是我在从Google获取浏览器API密钥时输入了错误的域名( referrer)。
修复Google API站点内引用域名(http://example.com/*)的名称为我解决了这个问题。
发布于 2016-06-24 14:42:34
用这个替换你的googleApi地图插件...
"https://maps.googleapis.com/maps/api/js?sensor=false&callback=initMap“
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
}
</script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false&callback=initMap"></script>
</body>
</html>
希望它能为你工作。
https://stackoverflow.com/questions/37603847
复制相似问题