[英]Google maps JavaScript v3 undefined error
I am trying to add a marker to a map in Google maps using JavaScript. 我正在尝试使用JavaScript在Google地图中的地图上添加标记。 The console on from Google Chrome is returning
"Uncaught TypeError: undefined is not a function"
. Google Chrome上的控制台返回
"Uncaught TypeError: undefined is not a function"
。 The error appears right after the map = new google.maps.Map
. 错误出现在
map = new google.maps.Map
。 However if I take out the Marker code the map appears and there are no errors. 但是,如果我删除了标记代码,地图就会出现,并且没有错误。
The code I am using is 我正在使用的代码是
<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),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.