当我有一个谷歌地图以下初始化:谷歌地图初始化不能看地图变量添加标记
function initialize()
{
var mapOptions = {
zoom: 15,
center: myLatLng,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
},
zoomControl: true,
scaleControl: true,
scrollwheel: true,
disableDoubleClickZoom: true,
};
var map = new google.maps.Map(document.getElementById("googleMap"),
mapOptions);
}
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: 'Hello World!'
});
google.maps.event.addDomListener(window, "load", initialize);
};
当试图添加的标记,我得到的错误:
Uncaught ReferenceError: map is not defined
如何查看此地图或向地图添加标记?
我得到的错误是'Uncaught ReferenceError:myLatLng is not defined'。在'initialize'函数中移动标记的定义(当前'map'变量是函数的局部变量)。 ([工作小提琴](http://jsfiddle.net/o6ncm9dd/1/)) – geocodezip