Google maps 通过单击隐藏标记Google Maps API v3

Google maps 通过单击隐藏标记Google Maps API v3,google-maps,google-maps-api-3,maps,google-maps-markers,show-hide,Google Maps,Google Maps Api 3,Maps,Google Maps Markers,Show Hide,我想通过点击HTML链接来隐藏标记。我已经写了一些代码,但不起作用。谁能告诉我怎么了 var markers = []; var cuicui= [ [45.710743, 4.934347], [45.691894, 4.923193], [45.713855, 4.928156], [45.710238, 4.965208], [45.713550, 4.930187], [45.712871, 4.928613],

我想通过点击HTML链接来隐藏标记。我已经写了一些代码,但不起作用。谁能告诉我怎么了

var markers = [];

var cuicui= [
     [45.710743, 4.934347],     
     [45.691894, 4.923193],
     [45.713855, 4.928156],
     [45.710238, 4.965208],
     [45.713550, 4.930187],
     [45.712871, 4.928613],
     [45.698959, 4.918937],
     [45.709566, 4.923370],
     [45.715945, 4.931199],
     [45.715824, 4.912740]
];

for (i = 0; i < cuicui.length; i++) {  
    var position = new google.maps.LatLng(cuicui[i][0], cuicui[i][1]),
      marker = new google.maps.Marker({
      position: position,
      map: map
    });

    markers.push(marker);

    google.maps.event.addListener(marker, 'click', (function(marker, i) {
      })(marker, i));   

    marker.setVisible(false);

    google.maps.event.addDomListener(document.getElementById('cuicui'), 'click', function () {
      if (marker.setVisible(false)) {
          marker.setVisible(true);
        } else {
          marker.setVisible(false);
        }
    });
} 
var标记=[];
var cuicui=[
[45.710743, 4.934347],     
[45.691894, 4.923193],
[45.713855, 4.928156],
[45.710238, 4.965208],
[45.713550, 4.930187],
[45.712871, 4.928613],
[45.698959, 4.918937],
[45.709566, 4.923370],
[45.715945, 4.931199],
[45.715824, 4.912740]
];
对于(i=0;i
在我的HTML中,我有:

  <a style="cursor : pointer;" id="cuicui">Ici</a>
Ici
(对不起我的英语。)

而不是setVisible();使用setMap()

使它出现并且

marker.setMap(null);

要使其不可见

请参见文档中的示例:谢谢您的回答,但它仍然不起作用。。。但是,没有报告任何错误
marker.setMap(null);