我需要一些帮助来在 Google Map 中创建一组标记,以便更高效,而不是一个一个地创建标记。我尝试了以下但它不起作用。有人有建议吗?
//create array to store a set of location
var collection = new Array();
//a set of locations stored in array
collection[0] = new google.maps.LatLng(13.742167701649997, 100.50721049308777);
collection[1] = new google.maps.LatLng(13.74428, 100.5404525);
collection[2] = new google.maps.LatLng(13.744108, 100.543098);
var pointMarkerImage = new Array();//store image of marker in array
var pointMarker = new Array();//store marker in array
//create number of markers based on collection.length
function setPoint(){
for(var i=0; i<collection.length; i++){
var pointMarkerImage[i] = new google.maps.MarkerImage('marker.png');
var pointMarker[i] = new google.maps.Marker({
position: collection[i],
map: map,
icon: pointMarkerImage[i],
animation: google.maps.Animation.BOUNCE,
title: "collection"+ i
});
google.maps.event.addListener(pointMarker[i], 'click', function() {
window.open("blog/page01.html","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=yes")
};
);
}
}