单击时让图标消失
let icons disappear when clicked
我希望街景视图中的图标在点击时消失。我尝试在 Jquery 中完成,这是我的代码:
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();
});
你们知道如何解决这个问题吗?
谢谢你的帮助!
您可以在 click
-回调中通过 this
访问标记:
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');
});
我希望街景视图中的图标在点击时消失。我尝试在 Jquery 中完成,这是我的代码:
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();
});
你们知道如何解决这个问题吗? 谢谢你的帮助!
您可以在 click
-回调中通过 this
访问标记:
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');
});