gpt4 book ai didi

javascript - 为什么这个简单的谷歌地图代码不起作用?

转载 作者:行者123 更新时间:2023-11-30 10:36:20 25 4
gpt4 key购买 nike


我正在使用 3.8 版 ,但没有 key 。我以前在我的桌面上使用过这个确切的代码(没有 key ),它工作得很好,但现在由于某种原因它不工作了。

我找不到任何拼写错误,没有 key 的导入声明是否与我正在使用的有所不同?

这是我的精简代码:

<!DOCTYPE html>
<html>
<head>
<title>asdfasdf</title>
</head>
<body onload = "initialize();">

<!-- map here -->
<div id = "map"></div>

<!-- Google Maps API -->
<script type = "text/javascript" src = "http://maps.googleapis.com/maps/api/js?&amp;sensor=true&amp;v=3.8"></script>

<script type = "text/javascript">

function initialize()
{
// object literal for map options
var myOptions =
{
center: new google.maps.LatLng(37.09024, -95.712891), // coordinates for center of map 30, 3
zoom: 4, // smaller number --> zoom out
mapTypeId: google.maps.MapTypeId.HYBRID // ROADMAP, SATELLITE, TERRAIN, or HYBRID
};

// note: if the id has a dash in its' name, map instantiation doesn't work!
var map = new google.maps.Map(document.getElementById("map"), myOptions);

} // end of initialize
</script>
</body>
</html>

最佳答案

它正在工作。也许您忘记为 map div 提供 width/height,所以您看不到它?

你可以在这里看看http://jsfiddle.net/2HmMQ/

关于javascript - 为什么这个简单的谷歌地图代码不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13854191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com