Something like this maybe (http://jsfiddle.net/uzV95/)? :
var pos = [
{
position: new google.maps.LatLng(-25.1, 131.044922),
action: function (e) {
document.location.href = "http://google.com"
}
},
{
position: new google.maps.LatLng(-25.363882, 131.044922),
action: function (e) {
infowindow.open(map, this);
}
}
],
markers = [],
infowindow = new google.maps.InfoWindow({
content: "hi"
}),
mapOptions = {
center: pos[0].position,
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
},
map = new google.maps.Map(document.getElementById("map"),
mapOptions);
pos.forEach(function (position) {
var marker = new google.maps.Marker({
position: position.position
});
marker.setMap(map);
google.maps.event.addListener(marker, 'click', position.action);
markers.push(marker);
});
Hope this helps!