user1562467
user1562467

Reputation: 11

link in Google Maps marker

I cannot get a link to work in my marker.

My code is:

var marker = new google.maps.Marker({ draggable: false, raiseOnDrag: false, icon: image, shape: shape, map: map, url: 'http://www.google.com/', position: myLatlng36, title:"My marker" });

It shows the marker perfectly on the right location, but nothing happens when I click it. I also tried adding

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

No result. Any suggestions?

Upvotes: 1

Views: 90

Answers (1)

chespinoza
chespinoza

Reputation: 2668

Did you test with?

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

Changing 'marker' to 'this'?

Upvotes: 3

Related Questions