-1

I want my icons in Street View disappear when clicked. I tried to do it in Jquery, this is my code:

  var image = 'bonus.png';
  var marker1 = new google.maps.Marker({
      position: new google.maps.LatLng(-5.758051,-35.207079),
      map: myPano,
      icon: image,
      height: 50

  });

  google.maps.event.addListener(marker1, 'click', function() {
                        $("marker1").unbind();
    });

Does any of you know how to fix this? Thanks for your help!

Tim
  • 5
  • 1

1 Answers1

1

You may access the marker via this in the click-callback:

google.maps.event.addListener(marker1, 'click', function() {

 //remove the marker
 this.setMap(null);

 //unbind the click
 //although it's unnecessary in this case
 this.unbind('click');
});
Dr.Molle
  • 116,463
  • 16
  • 195
  • 201
  • Or `this.setVisible(false)` see the [documentation](https://developers.google.com/maps/documentation/javascript/reference#Marker). – MrUpsidown Mar 23 '15 at 10:03