javascript - 谷歌地图 JavaScript v3 未定义错误

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

我正在尝试使用 JavaScript 将标记添加到 Google map 中的 map 。 Google Chrome 上的控制台返回“未捕获的类型错误:未定义不是函数”。该错误出现在 map = new google.maps.Map 之后。但是,如果我取出标记代码, map 就会出现并且没有错误。

我使用的代码是

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCs7h9k3_PHQpo8EBDf-GaVhf178Z3xSb4&sensor=false"></script>
<script type="text/javascript">
var map;
function initialize() {
   var mapOptions = {
   zoom: 8,
   center: new google.maps.LatLng(35.6017, -77.3725)
};

map = new google.maps.Map(document.getElementById('gmap'),
mapOptions);

var marker = new google.maps.Marker({
    position: new google.maps.Latlng(36, -77),
    map: map,
    title: 'Test' 
});

}
google.maps.event.addDomListener(window, 'load', initialize);
</script>   

最佳答案

position: new google.maps.Latlng(36, -77),

position: new google.maps.LatLng(36, -77),

关于javascript - 谷歌地图 JavaScript v3 未定义错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23576182/

相关文章:

javascript - 使用谷歌地图 API 和 phonegap 显示当前位置+方向?

javascript - 大量日期输入项的 Bootstrap Datepicker 性能问题

javascript - 使用直接输出将 JSON 从 PHP 传递到 Javascript

javascript - Uncaught Error : google is not defined for Google Map API geocoder

android - 如何在实时移动 map 时从android map 中心获取gps坐标

javascript - 删除 Google Maps API v3 中的标记

javascript - 错误 : WebGL warning: vertexAttribPointer: -1 is not a valid `index`

javascript - JS : styling windows. 打开

java - 如何在谷歌地图应用程序中添加此自定义信息窗口而不是默认窗口?

javascript - 在谷歌地图 v3 的绘图管理器中更改 "drawingMode"