无法生成 Google 地图
Cannot generate Google Map
我只是想为 Google 地图 Javascript API 获取简单地图 (https://developers.google.com/maps/documentation/javascript/examples/map-simple#maps_map_simple-javascript) 为我工作。
我有这个网页(我已经输入了 API 密钥并授予了访问 Javascript API 的密钥)
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
<style>
#map {
height: 100%;
}
</style>
<!-- jsFiddle will insert css and js -->
</head>
<body>
<div id="map"></div>
<!-- Async script executes immediately and must be after any DOM elements used in callback. -->
<script
src="https://maps.googleapis.com/maps/api/js?key=<MY SPI KEY>&callback=initMap&v=weekly&channel=2"
async
></script>
<script>
let map;
function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
center: { lat: -34.397, lng: 150.644 },
zoom: 8,
});
}
</script>
</body>
</html>
我生成了一个 html 页面,但代码生成的 iframe 实际上有一个空文档。是
<iframe aria-hidden="true" tabindex="-1" style="z-index: -1; position: absolute; width: 100%; height: 100%; top: 0px; left: 0px; border: medium none;" frameborder="0">
#document
<html>
<head></head>
<body></body>
</html>
</iframe>
我一定是遗漏了一些非常简单和基本的东西 - 请帮忙
我不知道为什么但是是的,当我尝试检查你的代码时我发现你没有添加 css 的正文和 google 地图给出的 html .当我添加它时,它会显示其中的内容。 CSS 我找到的代码如下-
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
请检查并回复
我只是想为 Google 地图 Javascript API 获取简单地图 (https://developers.google.com/maps/documentation/javascript/examples/map-simple#maps_map_simple-javascript) 为我工作。
我有这个网页(我已经输入了 API 密钥并授予了访问 Javascript API 的密钥)
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
<style>
#map {
height: 100%;
}
</style>
<!-- jsFiddle will insert css and js -->
</head>
<body>
<div id="map"></div>
<!-- Async script executes immediately and must be after any DOM elements used in callback. -->
<script
src="https://maps.googleapis.com/maps/api/js?key=<MY SPI KEY>&callback=initMap&v=weekly&channel=2"
async
></script>
<script>
let map;
function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
center: { lat: -34.397, lng: 150.644 },
zoom: 8,
});
}
</script>
</body>
</html>
我生成了一个 html 页面,但代码生成的 iframe 实际上有一个空文档。是
<iframe aria-hidden="true" tabindex="-1" style="z-index: -1; position: absolute; width: 100%; height: 100%; top: 0px; left: 0px; border: medium none;" frameborder="0">
#document
<html>
<head></head>
<body></body>
</html>
</iframe>
我一定是遗漏了一些非常简单和基本的东西 - 请帮忙
我不知道为什么但是是的,当我尝试检查你的代码时我发现你没有添加 css 的正文和 google 地图给出的 html .当我添加它时,它会显示其中的内容。 CSS 我找到的代码如下-
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
请检查并回复