所以这是我的代码。问题是地图显示,但地图上没有放置标记。latlongARR 是一个看起来像这样的数组
[{"name":"McChord Field DGC","lat":"47.128257","long":"-122.488847"},{"name":"环境 DGC","lat":"47.184732","long ":"-122.509232"},{"name":"Riverside Disc Golf Park","lat":"47.185683","long":"-122.212600"},{"name":"East Tacoma DGC"," lat":"47.227344","long":"-122.398491"},{"name":"白河","lat":"47.278501","long":"-122.197390"}]
似乎一切都应该工作?有什么明显的错误吗?
var mapOptions = {
zoom:10,
center: currentLocation,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('dgmap'), mapOptions);
var infowindow = null;
var infowindow = new google.maps.InfoWindow({content: 'loading...'});
var marker, i;
for(i=0; i < latlongARR.length; i++){
var markers;
marker = new google.maps.Marker({
position: new google.maps.LatLng(latlongARR[i][1], latlongARR[i][2]),
map:map
});
console.log(latlongARR[i][0]);
google.maps.event.addListener(marker, 'click', (function(marker, i){
return function(){
infowindow.setContent(latlongARR[i][0]);
infowindow.open(map, marker);
}
})(marker,i));
};
}