0

我正在尝试在 Google Maps API 上制作一些绘图的原型。我已经按照这里的代码并认为我的代码应该可以工作,但是我得到一个空白屏幕。所有的对象都有似乎是正确的数据,但可惜没有骰子。任何帮助,将不胜感激。

<!DOCTYPE html>
<html>
<head>
<title>Google Maps Test</title>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=<key removed>&sensor=false"></script>
<style type="text/css">
</style>
<script type="text/javascript">
function initialize() {
    var myLatLng = new google.maps.LatLng(33.001466, -97.354317);

    var mapOptions = {
        zoom:6,
        center:myLatLng,
        mapTypeId: google.maps.MapTypeId.TERRAIN
    };
    console.log(mapOptions);

    var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
    console.log(map);

    var routeCoordinates = [
        new google.maps.LatLng(33.001466, -97.354317),
        new google.maps.LatLng(33.025001, -97.352171),
        new google.maps.LatLng(33.033219, -97.341700),
        new google.maps.LatLng(33.049321, -97.320414),
        new google.maps.LatLng(33.051335, -97.304020),
        new google.maps.LatLng(33.059464, -97.298355),
        new google.maps.LatLng(33.083919, -97.295609),
        new google.maps.LatLng(33.111314, -97.291918),
        new google.maps.LatLng(33.136042, -97.289257),
        new google.maps.LatLng(33.182818, -97.287111)
    ];
    console.log(routeCoordinates);

    var routePath = new google.maps.Polyline({
        path:routeCoordinates,
        strokeColor:"#000000",
        strokeOpacity:.90,
        strokeWeight: 2,
        editable:false
    });
    console.log(routePath);

    routePath.setMap(map);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas">

</div>
</body>
</html>
4

1 回答 1

1

如果我删除密钥并给地图 div 一个大小,你的地图对我有用。

http://www.geocodezip.com/JohnSwaringenSO.html

于 2012-09-18T21:47:49.860 回答