我无法在 Google Maps V3 中显示多个标记,我得到了正确的坐标但没有显示在地图上。控制台中也没有错误
- map_items[0] = 标题
- map_items[1] = 55.153766, 11.909180
- map_items[2] = 链接
- map_items[3] = 文本
如果我发出警报,它们都会正确显示。例子
“标题”、“51.00150763193481、-2.5659284999999272”、“链接”、“文本”
function initialize() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 7,
center: new google.maps.LatLng(55.153766, 11.909180),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
for (var x = 0; x < temp.length; x++) {
if(temp[x][1]){
var map_items = temp[x];
var myLatlng = new google.maps.LatLng(map_items[1]);
var marker = new google.maps.Marker({
map: map,
position: myLatlng,
title: map_items[0]
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent('<div class="google_marker"><a href="'+map_items[2]+'">'+map_items[0]+'</a><br /><p>'+map_items[3]+'</p></div>');
infowindow.open(map, marker);
});
}
}
}