Set google maps marker as link not working

Hi,

I am trying to make links out of my google maps markers

My code looks like this:

var markers = [];

	  	markers[1] = new google.maps.Marker({
		    position: new google.maps.LatLng(62.561718, 14.545898),
		    icon: new google.maps.MarkerImage('../images/pin.png'),
		    title: "butik",
		    map: map,
		    url: 'link.php'
		});

	  	markers[2] = new google.maps.Marker({
		    position: new google.maps.LatLng(62.561718, 12.545898),
		    icon: new google.maps.MarkerImage('../images/pin.png'),
		    title: "butik",
		    map: map,
		    url: 'link.php'
		});

	  	markers[3] = new google.maps.Marker({
		    position: new google.maps.LatLng(61.561718, 16.545898),
		    icon: new google.maps.MarkerImage('../images/pin.png'),
		    title: "butik",
		    map: map,
		    url: 'link.php'
		});

		google.maps.event.addListener(marker, 'click', function() {
		    window.location.href = this.url;
		});

Can anyone help me?

Hi ReGGaeBOSS,

The problem is that you’re trying to assign an event listener to marker, which doesn’t exist. What you need to do is iterate over your markers array and attach a listener to each one individually.