Google地图未加载

时间:2015-01-22 20:30:14

标签: javascript html google-maps-api-3

我尝试了另一种加载Google地图的方法。但是,我得到了2个错误:

 //Uncaught SyntaxError: Unexpected token = (zoom =8,)
 //Uncaught ReferenceError: initialize is not defined onload

我已突出显示以粗体显示的错误

<html>
<head>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize()
{
    var latlng= new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
        **zoom = 8,**
        center: latlng,
        mapTypeId: google.maps,MapTypeId.ROADMAP
    };
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
</script>

</head>

**<body onload="initialize()">**
    <div id="map_canvas" style="width:400px;height:400px;">


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

1 个答案:

答案 0 :(得分:0)

您有语法错误,而不是

zoom = 8,

应该是

zoom: 8,