私のモニターにGoogleマップは表示されませんが、すべてのコードを単一のHTMLファイルに入れてスクリプトタグを使用すると動作します。Google Mapは別ファイルでロードされていません
index.htmlファイルは次のとおりです。
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<div id="map"></div>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBIpWlWVDAqVEyW20SX6MfThL-iz9IWeQA&callback=initMap"
></script>
</body>
</html>
Script.jsファイルは次のとおりです。
function initMap() {
var map;
map = new google.maps.Map(document.getElementById('map'),
{
center: { lat: -34.397,
lng: 150.644
},
zoom: 8
}
);
}
のstyle.cssファイルには、次のとおりです。
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
コンソールログにエラーがないかチェックしましたか? – navigator
yesコンソールログにエラーがありません –
マップdivにコンテンツが埋め込まれているかどうかブラウザで調べましたか? – arifCee