我在google云平台上生成了一个api密钥,并将其放入脚本中,但仍然不起作用。
/* 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 */
}
// 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});
}