我正在尝试在html页面上显示google maps javascript api,但未显示,并给我错误“无法加载资源net :: err_timed_out” 我在Google云端平台上生成了一个api密钥,并将其放入脚本中,但仍然无法正常工作。
<!DOCTYPE html>
<html>
<head>
<style>
/* Set the size of the div element that contains the map */
#map {
height: 400px; /* The height is 400 pixels */
width: 100%; /* The width is the width of the web page */
}
</style>
<!--The div element for the map -->
<div id="map" </div>
<script>
// Initialize and add the map
function initMap() {
/ The location
var location = {lat: 36.512483,lng: -115.064985};
// The map, centered at location
var map = new google.maps.Map(
document.getElementById('map'), {zoom: 8, center: location});
// The marker, positioned at location
var marker = new google.maps.Marker({position: location, map: map});
}
</script>
<!--Load the API from the specified URL
* The async attribute allows the browser to render the page while the API loads
* The key parameter will contain your own API key (which is not needed for this tutorial)
* The callback parameter executes the initMap() function
-->
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAnW5hF37VGcliSVTP7NRMS2Mz8kGORvEQ&callback=initMap" ></script>
</body>
</html>